Match Linux SCSI Devices (sdX) to Virtual Disks in VMware

To determine the SCSI ID from device names enter ls -d /sys/block/sd*/device/scsi_device/*

debian02:~ # ls -d /sys/block/sd*/device/scsi_device/*
/sys/block/sda/device/scsi_device/0:0:0:0 /sys/block/sde/device/scsi_device/0:0:4:0 /s
/sys/block/sdb/device/scsi_device/0:0:1:0 /sys/block/sdf/device/scsi_device/0:0:5:0 /s
/sys/block/sdc/device/scsi_device/0:0:2:0 /sys/block/sdg/device/scsi_device/0:0:6:0 /s
/sys/block/sdd/device/scsi_device/0:0:3:0 /sys/block/sdh/device/scsi_device/0:0:8:0 /s
debian02:~ #

You can see the the device name, and 4 numbers a:b:c:d

a = Hostadapter ID
b = SCSI channel
c = Device ID
d = LUN

The Device ID is always c. At the controller, it depends whether you are using the Paravirtual (b) controller, or the LSI Logic (a) controller.

On the VMware it looks like that:

debian02
/dev/sda has the SCSI ID 0:0:0:0 which is the equivalent to 0:0 and is Hard Disk 1 on VMware.
/dev/sde has the SCSI ID 0:0:4:0 which is the equivalent to 0:4 and is Hard Disk 5 on VMware.
/dev/sdo has the SCSI ID 0:0:15:0 which is the equivalent to 0:15 and is Hard Disk 16 on VMware.

When you remove and add disks, the order might change so always double check if you want to remove disks from a Virtual Machine.

Also you can use the following command if you want an output that is better to read:

debian02:~ # ls -d /sys/block/sd*/device/scsi_device/* |awk -F '[/]' '{print $4,"- SCSI",$7}'
sda - SCSI 0:0:0:0
sdb - SCSI 0:0:1:0
sdc - SCSI 0:0:2:0
sdd - SCSI 0:0:3:0
sde - SCSI 0:0:4:0
sdf - SCSI 0:0:5:0
sdg - SCSI 0:0:6:0
sdh - SCSI 0:0:8:0
sdi - SCSI 0:0:9:0
sdj - SCSI 0:0:10:0
sdk - SCSI 0:0:11:0
sdl - SCSI 0:0:12:0
sdm - SCSI 0:0:13:0
sdn - SCSI 0:0:14:0
sdo - SCSI 0:0:15:0
debian02:~ #

Leave a Reply

Your email address will not be published. Required fields are marked *

*