Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command to list disks 1

Status
Not open for further replies.

terrywashington

Technical User
Jun 28, 2001
185
US
Is there a Redhat/Fedora command that lists the disks in a system (similar to the format or iostat -En command in Solaris)?
 
If I could remember what either of those solaris commands actually displays, I might be able to tell you :)

What info are you actually after?

Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
I am looking for a quick way to identify the disks in (or attached) to a system. Here is an example of the format and iostat output from a Solaris system. It would also be nice to get the capacity and model info.

# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
0. c0t0d0 <WDC WD800JB-00FSA0 cyl 38307 alt 2 hd 16 sec 255>
/pci@1f,0/ide@d/dad@0,0
1. c0t2d0 <WDC WD800JB-00FMA0 cyl 38307 alt 2 hd 16 sec 255>
/pci@1f,0/ide@d/dad@2,0
Specify disk (enter its number): ^D


# iostat -En
c0t0d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Model: WDC WD800JB-00FS Revision: 77.07W77 Serial No: WD-WCAJD1091446
Size: 80.02GB <80023879680 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0
c0t2d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Model: WDC WD800JB-00FM Revision: 13.03G13 Serial No: WD-WCAJ91062415
Size: 80.02GB <80023879680 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0
c0t1d0 Soft Errors: 104 Hard Errors: 3 Transport Errors: 0
Vendor: PIONEER Product: 12X DVD-ROM Revision: 1.14 Serial No:
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 3 No Device: 0 Recoverable: 0
Illegal Request: 104 Predictive Failure Analysis: 0
 
could be a mix between [tt]cat /proc/diskstat [/tt] and [tt]hdparm -i device[/tt] ??

Cheers.
 
Thanks for the info. I will try the diskstats and the hdparm commands.
 
Well, to list the devices (doesn't show geometry though) I use:

Code:
dmesg | grep ^[hs]d[a-z]:

That will produce a listing like:

Code:
hda: QUANTUM FIREBALL CX10.2A, ATA DISK drive
hdc: NEC CD-ROM DRIVE:285, ATAPI CD/DVD-ROM drive
hda: max request size: 128KiB
hda: 20044080 sectors (10262 MB) w/418KiB Cache, CHS=19885/16/63, (U)DMA
hda: cache flushes not supported
hdc: ATAPI 12X CD-ROM drive, 128kB Cache, DMA

I honestly don't know what you could use to identify the geometry though, maybe a bash script could be written to get that information from /proc/diskstats as mentioned above.
 
Oops, it does show the geometry in the above output.
 
Once you have the device you can get the geometry from fdisk:
Code:
s5(~)$ sudo fdisk /dev/hda

Command (m for help): p

Disk /dev/hda: 4303 MB, 4303272960 bytes
255 heads, 63 sectors/track, 523 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14          77      514080   82  Linux swap
/dev/hda3              78         523     3582495   8e  Linux LVM

Command (m for help): Command (m for help): q

If you want to know where fdisk gets that info from, Use the Source, Luke.
 
Right - and for more ease, use sfdisk - nothing to exit from, and you can even request geometry specifically if that's all you want:

# sfdisk -g
/dev/sda: 9729 cylinders, 255 heads, 63 sectors/track
/dev/sda1: 65 cylinders, 255 heads, 63 sectors/track
/dev/sda2: 255 cylinders, 255 heads, 63 sectors/track
/dev/sda5: 637 cylinders, 255 heads, 63 sectors/track
/dev/sda6: 637 cylinders, 255 heads, 63 sectors/track
/dev/sda7: 8131 cylinders, 255 heads, 63 sectors/track

# sfdisk -l

Disk /dev/sda: 9729 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 0+ 65 66- 530113+ 83 Linux
/dev/sda2 66 320 255 2048287+ 82 Linux swap
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 321 9728 9408 75569760 5 Extended
/dev/sda5 321+ 958 638- 5124703+ 83 Linux
/dev/sda6 959+ 1596 638- 5124703+ 83 Linux
/dev/sda7 1597+ 9728 8132- 65320258+ 83 Linux


Tony Lawrence
Linux/Unix/Mac OS X Resources
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top