Here's an easy question for you guys: How do I find out what hard drives are attached to a linux box? I'm hoping for a single command that can give me a nice list of all ata/scsi/etc drives.

I've catted /proc/partitions in the past to do this, but I wonder if that still works if there's a drive with no partitions on it.

link|improve this question
feedback

5 Answers

up vote 11 down vote accepted

sudo lshw -class disk

gives you everything but the mount point

  *-cdrom                 
       description: CD-R/CD-RW writer
       product: 52MAXX 3252AJ
       vendor: Memorex
       physical id: 0
       bus info: scsi@0:0.0.0
       logical name: /dev/cdrom
       logical name: /dev/cdrw
       logical name: /dev/scd0
       logical name: /dev/sr0
       version: QWS3
       capabilities: removable audio cd-r cd-rw
       configuration: ansiversion=5 status=nodisc
  *-disk:0
       description: SCSI Disk
       product: ZIP 100
       vendor: IOMEGA
       physical id: 0.1.0
       bus info: scsi@0:0.1.0
       logical name: /dev/sda
       version: 12.A
       capabilities: removable
       configuration: ansiversion=5
     *-medium
          physical id: 0
          logical name: /dev/sda
  *-disk:1
       description: ATA Disk
       product: WDC WD800AB-00CB
       vendor: Western Digital
       physical id: 1
       bus info: scsi@1:0.0.0
       logical name: /dev/sdb
       version: 04.0
       serial: WD-WCAA52477019
       size: 74GiB (80GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 signature=90909090

sudo lshw -class disk -html

link|improve this answer
That's pretty good. – Luke May 6 '09 at 5:01
2  
I would use "lshw -C disk -C volume" to also include the partitions – Nils-Anders Nøttseter May 6 '09 at 5:22
feedback

fdisk -l

link|improve this answer
One problem I have with with fdisk is that it also shows or errors on dm-crypt devices, or lvm devices, sometimes I like to see the actual disks. – Zoredache May 5 '09 at 22:19
+1 as the default installes for Ubuntu and Debian I have access to don't have lshw – Greg B May 29 '09 at 10:34
feedback

An alternative to lshw:

hwinfo --disk

Also has '--short' option, if you're only interested in the /dev and model name and not all the details.

hal9k:~ # hwinfo --disk --short
disk:
  /dev/sda             Hitachi HDT72502
  /dev/sdb             Generic USB SD Reader
  /dev/sdc             Generic USB CF Reader
  /dev/sdd             Generic USB SM Reader
  /dev/sde             Generic USB MS Reader

Long version gives you more details then lshw:

hal9k:~ # hwinfo --disk 
16: IDE 200.0: 10600 Disk                                       
  [Created at block.243]                                        
  UDI: /org/freedesktop/Hal/devices/storage_serial_SATA_Hitachi_HDT7250_VFL104R62EUUTX
  Unique ID: 3OOL.JSHCimqnHw6                                                         
  Parent ID: CvwD.epf1vnVqQVC                                                         
  SysFS ID: /class/block/sda                                                          
  SysFS BusID: 2:0:0:0                                                                
  SysFS Device Link: /devices/pci0000:00/0000:00:05.0/host2/target2:0:0/2:0:0:0       
  Hardware Class: disk                                                                
  Model: "Hitachi HDT72502"                                                           
  Vendor: "Hitachi"                                                                   
  Device: "HDT72502"                                                                  
  Revision: "V5DO"                                                                    
  Serial ID: "VFL104R62EUUTX"                                                         
  Driver: "sata_sis", "sd"                                                            
  Driver Modules: "sata_sis"                                                          
  Device File: /dev/sda                                                               
  Device Files: /dev/sda, /dev/disk/by-id/scsi-SATA_Hitachi_HDT7250_VFL104R62EUUTX, /dev/disk/by-id/ata-Hitachi_HDT725025VLA380_VFL104R62EUUTX, /dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0, /dev/disk/by-id/edd-int13_dev80                                                                                                                                        
  Device Number: block 8:0-8:15                                                                                                                                                     
  BIOS id: 0x80                                                                                                                                                                     
  Geometry (Logical): CHS 30401/255/63                                                                                                                                              
  Size: 488397168 sectors a 512 bytes                                                                                                                                               
  Geometry (BIOS EDD): CHS 484521/16/63                                                                                                                                             
  Size (BIOS EDD): 488397168 sectors                                                                                                                                                
  Geometry (BIOS Legacy): CHS 1023/255/63                                                                                                                                           
  Config Status: cfg=no, avail=yes, need=no, active=unknown                                                                                                                         
  Attached to: #9 (IDE interface)                                                                                                                         

[...]

EDIT:

As for the packages availability. I'm using OpenSUSE 11.1. hwinfo is in the standard repository, while lshw is only available from unofficial one.

link|improve this answer
But you need the hwinfo package installed for this to work :'( – Andor May 6 '09 at 9:33
@Andor: true, but to have lshw you also need to install the package. – vartec May 6 '09 at 9:59
feedback

/proc/diskstats will have stats on all your extant drives, whether or not they have partitions on them.

link|improve this answer
feedback

I like lshw -class disk

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.