vCenter

 View Only
Expand all | Collapse all

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

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

    Posted Apr 15, 2014 07:07 PM

    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.



  • 2.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Apr 16, 2014 01:40 AM

    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.



  • 3.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Apr 16, 2014 05:59 AM

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



  • 4.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Apr 16, 2014 07:55 AM

    Hi ssuvasanth,

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

    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



  • 5.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Jul 28, 2022 01:03 PM

    Hi  

    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?



  • 6.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Dec 02, 2022 09:32 AM

    you should enable uuid on vm level



  • 7.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Broadcom Employee
    Posted Apr 16, 2014 10:26 AM

    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:

    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 :smileyhappy:



  • 8.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Oct 20, 2014 05:33 PM

    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




  • 9.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Aug 05, 2015 07:49 PM

    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



  • 10.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Nov 14, 2016 10:22 AM

    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.





  • 11.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Dec 19, 2017 12:37 PM

    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 :smileysad:



  • 12.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Sep 27, 2019 10:27 AM

    Hi,

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

    :smileyhappy:



  • 13.  RE: How to find the corresponding vmdk of the /dev/sd* disk added in linux system?

    Posted Nov 25, 2019 03:27 PM

    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