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.

10 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.

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).

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

0 Kudos
sajal1
VMware Employee
VMware Employee

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

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


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

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

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

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

0 Kudos