I'm interested which devices in /sys/block are real HDD drives:

[root@sdp1a block]# pwd
[root@sdp1a block]# ls
dm-0   dm-12  dm-3  dm-7   loop1  loop5  ram1   ram13  ram3  ram7  sdaa  sdae  sdai  sdam  sdaq  sdau  sday  sdbb  sdbf  sdc  sdg  sdk  sdo  sds  sdw
dm-1   dm-13  dm-4  dm-8   loop2  loop6  ram10  ram14  ram4  ram8  sdab  sdaf  sdaj  sdan  sdar  sdav  sdaz  sdbc  sdbg  sdd  sdh  sdl  sdp  sdt  sdx
dm-10  dm-14  dm-5  dm-9   loop3  loop7  ram11  ram15  ram5  ram9  sdac  sdag  sdak  sdao  sdas  sdaw  sdb   sdbd  sdbh  sde  sdi  sdm  sdq  sdu  sdy
dm-11  dm-2   dm-6  loop0  loop4  ram0   ram12  ram2   ram6  sda   sdad  sdah  sdal  sdap  sdat  sdax  sdba  sdbe  sdbi  sdf  sdj  sdn  sdr  sdv  sdz
[root@sdp1a block]#

How I can understand this?


Whether a block device is a real HDD can be derived from the major device number corresponding to the disk driver as documented in man sd and man 4 hd:
SCSI and SATA disks have major 8, old IDE disks 3 or 22.

You can see these in /proc/devices or parse the /sys/block/*/dev files:
cd /sys/block; grep -lE '^(8|3|22):' */dev | sed 's-/dev--'

When this is run in a virtual machine, results depend on virtualization type:
With Hardware virtualization, behavior is as above except for PVHVM (see below).
With Paravirtualization, things change. For instance, XEN xvd driver uses major 202.
This is also true for PVHVM as used on Amazon EC2, for example.
Thus you need additional measures to achieve your desired result on VMs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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