VMware Cloud Community
ssuvasanth
Contributor
Contributor

How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

Hi,

I have a situation where there are 3 disks -> /dev/sdj, /dev/sdk, /dev/sdl -> all 3 of same size in a RHEL system.

I want to remove a disk(/dev/sdj) from the system from Vsphere.

How to find the corresponding .vmdk name?

I have been trying.

Needing your help.

12 Replies
will373794
Enthusiast
Enthusiast

You should be able to tell from the VM's properties ( In vmware client, right click VM -> Edit Settings -> The hard disk you want to remove ). You can tell by size or SCSI node which should be in same order as in linux.

Reply
0 Kudos
kashifkarar01
Enthusiast
Enthusiast

hi,

In our vm which is running with RHEL 6. I notice that /dev/sdb, /dev/sdc and /dev/sdd and mapped to hard disk 1, hardisk 2 and harddisk 3 . You can co relate this at the VMs edit settings.

NOTE: While removing the Hardisk from VM make sure that you just remove the .vmdk from the VM and do not select the option delete from disk. In this way you can be in safer side and if everything works out as expected you can manually delete the .vmdk file from Datastore (If you wish).

Reply
0 Kudos
macvirtual
Enthusiast
Enthusiast

Hi ssuvasanth,

It's easy to identify the device file(/dev/sdX) and VMware virtual hard disk.

vhdd.PNG

right click your virtual machine on the vCenter ( or vSphere Client), and click "Edit Settings".

You will see your virtual hard disk as above.

On the right pane, SCSI address shows up like "SCSI(0:0)". The number of the SCSI(X:X) can map to Linux device file such as;

SCSI(0:0) -> /dev/sda

SCSI(0:1) -> /dev/sdb

 ・

 ・

 ・

So I guess /dev/sdj, which you wish to delete, SCSI(0:10). Note that the virtual hard disk name "Hard disk X" is not necessarily corresponding to /dev/sdX.

This mapping is based on Linux device naming mechanism, thus if you customize this configuration, say using /etc/udev.rules, you should check Red Hat document before you delete your vdisk.

Best,

MAC

Reply
0 Kudos
sajal1
Hot Shot
Hot Shot

Hello,

The best way to do it a mix of the above and the following:

Run the command "lssci". A sample output is provided below:

Capture.JPG

Next follow the above suggestion from macvirtual to find out the mapping of the disks with the VMDK. Now you are sure and safe to know which is which.

Hope this helps Smiley Happy

Reply
0 Kudos
UofS
Enthusiast
Enthusiast

We have found that when using multiple pvscsi controllers the only reliable thing one can count on seems to be the LUN number.  Controller host (first column) is completely random.   We believe that the only way to reliably map these is to embed the controller and LUN id into the label or volume group name (assuming 1 vmdk per volume group)

If there are any linux method to sequentially map the host controllers this would make it more reliable.


Ideas anyone?


eg:


[0:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda

[0:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb

[0:0:2:0]    disk    VMware   Virtual disk     1.0   /dev/sdc

[1:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sdd

[1:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sde

[2:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sdf

[2:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdg

[3:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sdh

[3:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdi

^


Update: The following link describes the problem and we believe the problem is as stated that the pvSCSI driver just does now pass the info through such as the wwn for the controller.


vmware esx - How does Linux determine the SCSI address of a disk? - Server Fault


Reply
0 Kudos
UnixArena
Contributor
Contributor

1. Use the dmesg command to find the existing disk SCSI ID and try to map it with VMware scsi id.

2. Pefrom the sg name validation on Linux to get the exact hard-disk name in the virtual Machine level.

For step by step guide, Please go through the below link.

How to Map the VMware virtual Disks for Linux VM ? - UnixArena

Reply
0 Kudos
suyashjain
Contributor
Contributor

dmesg is the easiest way to map the disk with vmdk files.

execute the following command on your linux.

# dmesg | grep -i 'Attached SCSI disk'

sample outout.

sd 2:0:1:0: [sdb] Attached SCSI disk

sd 2:0:3:0: [sdd] Attached SCSI disk

sd 2:0:6:0: [sdg] Attached SCSI disk

sd 2:0:4:0: [sde] Attached SCSI disk

sd 2:0:0:0: [sda] Attached SCSI disk

sd 2:0:5:0: [sdf] Attached SCSI disk

sd 2:0:2:0: [sdc] Attached SCSI disk

now match second and third number from first column sd '2:0:1:0' with VMWARE scsi Id mentioned in VM properties as mentioned in above screen shot.



diringer
Contributor
Contributor

now match second and third number from first column sd '2:0:1:0' with VMWARE scsi Id mentioned in VM properties as mentioned in above screen shot.

sorry to say that: but that is not correct. The second number is always 0 here.

And there is no relation between the first number and the number of the SCSI Controller in VM Propierties. (though it is very often the same, but you cannot rely on that)

So after years: this question is still open to be answered Smiley Sad

Reply
0 Kudos
Telecodani1
Contributor
Contributor

Hi,

I think the second zero is for Bus Number and the third is for the Unit Number.

Smiley Happy

Reply
0 Kudos
usn
Contributor
Contributor

Using UDEV would simplify things greatly.

https://www.usn-it.de/2019/11/25/make-linux-disk-ids-visible-for-udev-in-vmware/


Regards

Martin Klier

Reply
0 Kudos
fmnet
Contributor
Contributor

Hi @macvirtual 

Thanks for your post. 

I am also trying to correlate devices onlinux and vmware disks. 

In my case, on linux when run pv command, it returns:

PVPSize
/dev/sdf11.36t
/dev/sdg13.29t
/dev/sdh1400.00g
/dev/sdi1200.00g
/dev/sdj1300.00g
/dev/sdk1250.00g
/dev/sdb15.00t
/dev/sdb2376.70g
/dev/sdb3500.00g
/dev/sdb4560.00g
/dev/sdb5123.30g
/dev/sdb6500.00g
/dev/sdf21.93t
/dev/sdm1400.00g
/dev/sdn1350.00g
/dev/sdp1500.00g
/dev/sdq1500.00g
/dev/sdl1510.00g
/dev/sdo1500.00g

 

All of them are lvm2. 

In My vm settings:

HDTypeSCSI idSize
HD1VDISKSCSI (0:0)180
HD2RAWSCSI (0:1)7180
HD3RAWSCSI (0:2)100
HD4RAWSCSI (0:3)1024
HD5RAWSCSI (0:4)130
HD6RAWSCSI (0:6)3372
HD7RAWSCSI (0:8)3372
HD8VDISKSCSI (0:5)400
HD9VDISKSCSI (0:9)200
HD10VDISKSCSI (0:10)300
HD11VDISKSCSI (0:11)250
HD12VDISKSCSI (0:12)500
HD13VDISKSCSI (1:0)510
HD14VDISKSCSI (1:1)400
HD15VDISKSCSI (1:2)350
HD16VDISKSCSI (1:3)500
HD17VDISKSCSI (1:4)500

 

So i can´t correlate SCSI(0:0) -> /dev/sda, SCSI(0:1) -> /dev/sdb and so on... 

What do you suggest?

Reply
0 Kudos
Lucas1981
Contributor
Contributor

you should enable uuid on vm level

Reply
0 Kudos