# Disk info



## balanga (Mar 2, 2018)

What commands can I use to give me as much information as possible about disks?

I'm aware  diskinfo(8) smartctl(8) and gpart(1)

Is there anything else?


----------



## ralphbsz (Mar 2, 2018)

Answering this fully would take me a day, mostly copying stuff from SATA and SCSI manuals.

About the hardware:

For SATA disks: run `camcontrol identify`.

For SCSI disks: run `camcontrol inquiry`, or `sg_inq` (if you are serious about disks, you have to install the sg utils package).  Note that in the inquiry command to the disk, you can request various pages; most modern disk drives have about a dozen pages worth of information they can give you.  If you tell `sg_inq` to give you page 0, it will give you a list of all pages the drive has.  This gives you information about the identity and vital product data of the disk.

The next set of questions are the operating parameters of the disk.  In SCSI, reading those is called "mode sense", and there is a command to read them in sg_utils call `sg_modes`.  I think the listing of all mode pages in the SCSI standard is about a hundred pages long.  You can download versions of the SCSI manual that pertain your drive from the manufacturer's web page, Seagate for example is very good about having model-specific SCSI manuals (each hundreds of pages long).  Read about those.

Then you need the capacity of the disk, and the "sector size" (correctly called the logical and physical block size).  Use the "read capacity" SCSI command in the guise of `sg_readcap`.

About the data on the drive: The `gpart` command you gave above is the starting point.


----------



## Snurg (Mar 3, 2018)

By the way, I do not know what's wrong with sysutils/sg3_utils.
I needed that for reformatting a bunch of NetApp drives to 512-byte sectors a while ago.
But all these sg_utils missed after installing that on FreeBSD.
I had to install Debian Linux, do `apt install sg_utils`, and all tools were available so that I could do the work...


----------



## balanga (Mar 4, 2018)

ralphbsz said:


> Answering this fully would take me a day, mostly copying stuff from SATA and SCSI manuals.
> 
> About the hardware:
> 
> ...



I'm sure you've forgotten more about hard disk than I will ever learn 

I haven't used SCSI for over 10 years so I won't pursue, but I'll read up on camcontrol(8).


----------



## ralphbsz (Mar 4, 2018)

Snurg said:


> By the way, I do not know what's wrong with sysutils/sg3_utils.
> I needed that for reformatting a bunch of NetApp drives to 512-byte sectors a while ago.
> But all these sg_utils missed after installing that on FreeBSD.


Strange.  I actually don't have any SCSI disks in use at home, and no SCSI controller in my machine, so I can't test them.  The sg_utils actually started life on *BSD; for that reason, their Linux source code is quite screwy: the internal data structures are all in BSD-style formats, and there is a front-end layer that converts them to Linux style.


----------

