How to find out the hard disk corresponding to the disk device in VMware virtual machine (Linux)

Posted by jonybhi on Mon, 04 May 2020 22:34:19 +0200

In VMware virtual machine (Linux), our Linux server may have multiple disks (or virtual disks), as shown below. The disks of this server include hard disk 1, hard disk 2 The hard disk 10 has a total of 10 hard disks.

 

 

In Linux system, the corresponding devices in the disk are as follows

 

[root@mylnx01 ~]# ls -lrt /dev/sd*
brw-r----- 1 root disk 8,   0 Apr 30 09:53 /dev/sda
brw-r----- 1 root disk 8,   3 Apr 30 09:53 /dev/sda3
brw-r----- 1 root disk 8,   2 Apr 30 09:53 /dev/sda2
brw-r----- 1 root disk 8,  21 Apr 30 09:53 /dev/sdb5
brw-r----- 1 root disk 8,  18 Apr 30 09:53 /dev/sdb2
brw-r----- 1 root disk 8,  17 Apr 30 09:53 /dev/sdb1
brw-r----- 1 root disk 8,  16 Apr 30 09:53 /dev/sdb
brw-r----- 1 root disk 8,  37 Apr 30 09:53 /dev/sdc5
brw-r----- 1 root disk 8,  34 Apr 30 09:53 /dev/sdc2
brw-r----- 1 root disk 8,  33 Apr 30 09:53 /dev/sdc1
brw-r----- 1 root disk 8,  32 Apr 30 09:53 /dev/sdc
brw-r----- 1 root disk 8,  64 Apr 30 09:53 /dev/sde
brw-r----- 1 root disk 8,  49 Apr 30 09:53 /dev/sdd1
brw-r----- 1 root disk 8,  48 Apr 30 09:53 /dev/sdd
brw-r----- 1 root disk 8,  82 Apr 30 09:53 /dev/sdf2
brw-r----- 1 root disk 8,  81 Apr 30 09:53 /dev/sdf1
brw-r----- 1 root disk 8,  80 Apr 30 09:53 /dev/sdf
brw-r----- 1 root disk 8,  69 Apr 30 09:53 /dev/sde5
brw-r----- 1 root disk 8,  65 Apr 30 09:53 /dev/sde1
brw-r----- 1 root disk 8, 113 Apr 30 09:53 /dev/sdh1
brw-r----- 1 root disk 8, 112 Apr 30 09:53 /dev/sdh
brw-r----- 1 root disk 8,  96 Apr 30 09:53 /dev/sdg
brw-r----- 1 root disk 8,  85 Apr 30 09:53 /dev/sdf5
brw-r----- 1 root disk 8, 129 Apr 30 09:53 /dev/sdi1
brw-r----- 1 root disk 8, 128 Apr 30 09:53 /dev/sdi
brw-r----- 1 root disk 8, 101 Apr 30 09:53 /dev/sdg5
brw-r----- 1 root disk 8,  97 Apr 30 09:53 /dev/sdg1
brw-r----- 1 root disk 8, 130 Apr 30 09:53 /dev/sdi2
brw-r----- 1 root disk 8, 147 Apr 30 09:53 /dev/sdj3
brw-r----- 1 root disk 8, 146 Apr 30 09:53 /dev/sdj2
brw-r----- 1 root disk 8, 145 Apr 30 09:53 /dev/sdj1
brw-r----- 1 root disk 8, 144 Apr 30 09:53 /dev/sdj
brw-r----- 1 root disk 8, 152 Apr 30 09:53 /dev/sdj8
brw-r----- 1 root disk 8, 151 Apr 30 09:53 /dev/sdj7
brw-r----- 1 root disk 8, 150 Apr 30 09:53 /dev/sdj6
brw-r----- 1 root disk 8, 149 Apr 30 09:53 /dev/sdj5
brw-r----- 1 root disk 8, 148 Apr 30 09:53 /dev/sdj4
brw-r----- 1 root disk 8, 153 Apr 30 09:53 /dev/sdj9
brw-r----- 1 root disk 8,   1 Apr 30 09:53 /dev/sda1

 

So how do we find out which disk / dev/sdj corresponds to in VMware? I believe that many students may want to judge by disk size, but this is not easy to judge or accurate by disk size, mainly due to the following factors:

 

1: The disk size is calculated differently on both sides. The disk size you see is a little different.

 

2: There may be disks of the same size. How do you judge at this time?

 

Is there a sign to judge it? According to the SCSI standard, each SCSI disk has a WWID, which is similar to the MAC address of the network card, and is unique. The / dev / disk / by ID directory on a Linux system contains the WWID access path for each SCSI disk.

 

[root@KerryDB ~]# ll /dev/disk/by-id/
total 0
lrwxrwxrwx. 1 root root  9 Apr 11 09:25 ata-ST500DM002-1BD142_Z6EA17FP -> ../../sda
lrwxrwxrwx. 1 root root 10 Apr 11 09:25 ata-ST500DM002-1BD142_Z6EA17FP-part1 -> ../../sda1
lrwxrwxrwx. 1 root root 10 Apr 11 09:25 ata-ST500DM002-1BD142_Z6EA17FP-part2 -> ../../sda2
lrwxrwxrwx. 1 root root 10 Apr 11 09:25 ata-ST500DM002-1BD142_Z6EA17FP-part3 -> ../../sda3
lrwxrwxrwx. 1 root root 10 Mar 10 14:29 dm-name-centos-home -> ../../dm-2
lrwxrwxrwx. 1 root root 10 Mar 10 14:29 dm-name-centos-root -> ../../dm-0
lrwxrwxrwx. 1 root root 10 Mar 10 14:29 dm-name-centos-swap -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Mar 10 14:29 dm-uuid-LVM-OoLL2Ne7hVrlu1rWFZRicmPrEZGxlZhQ2GwVhfhZrdLWmRZ3KuKGNJJqskLn2noy -> ../../dm-0
lrwxrwxrwx. 1 root root 10 Mar 10 14:29 dm-uuid-LVM-OoLL2Ne7hVrlu1rWFZRicmPrEZGxlZhQNALIUTdrhqV42RQNW8jaImopDuEPs5b3 -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Mar 10 14:29 dm-uuid-LVM-OoLL2Ne7hVrlu1rWFZRicmPrEZGxlZhQybFeXSOtclTjcV0dS9tKiwA1IVBwxnrK -> ../../dm-2
lrwxrwxrwx. 1 root root 10 Apr 11 09:25 lvm-pv-uuid-FAYN5y-YdiR-CywU-1vDf-Btz6-dkyt-TNy8ee -> ../../sda3
lrwxrwxrwx. 1 root root  9 Apr 11 09:25 wwn-0x5000c5007911cd0c -> ../../sda
lrwxrwxrwx. 1 root root 10 Apr 11 09:25 wwn-0x5000c5007911cd0c-part1 -> ../../sda1
lrwxrwxrwx. 1 root root 10 Apr 11 09:25 wwn-0x5000c5007911cd0c-part2 -> ../../sda2
lrwxrwxrwx. 1 root root 10 Apr 11 09:25 wwn-0x5000c5007911cd0c-part3 -> ../../sda3

 

But in the current environment, VMware virtual machine (Linux) does not turn on this option by default.

 

# ll /dev/disk/by-id
ls: /dev/disk/by-id: No such file or directory
# cd /dev/disk
# ls -lrt
total 0
drwxr-xr-x 2 root root  60 May  3 19:35 by-uuid
drwxr-xr-x 2 root root  60 May  3 19:35 by-label
drwxr-xr-x 2 root root 640 May  3 19:35 by-path

 

Moreover, if you connect VMware vSphere Client to VMware console, you will find that there is no WWID information of the hard disk. Even if you find the WWID information of the device in Linux, you can't see the corresponding WWID information in VMware console. We can also judge it by the SCSI number of the computer It can be applied to many devices (including random access devices, such as disks and sequential storage devices such as tape). As shown in the screenshot below, disks are managed by SCSI controller, and hard disk 9 corresponds to SCSI (0:11)

 

 

 

 

 

[root@mylnx01 ~]# ll /dev/disk/by-path | grep '0:11'
lrwxrwxrwx 1 root root  9 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0 -> ../../sdj
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part1 -> ../../sdj1
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part2 -> ../../sdj2
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part3 -> ../../sdj3
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part4 -> ../../sdj4
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part5 -> ../../sdj5
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part6 -> ../../sdj6
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part7 -> ../../sdj7
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part8 -> ../../sdj8
lrwxrwxrwx 1 root root 10 Apr 30 09:53 pci-0000:00:10.0-scsi-0:0:11:0-part9 -> ../../sdj9
 
[root@mylnx01 ~]# ls -l /dev/sdj*
brw-r----- 1 root disk 8, 144 Apr 30 09:53 /dev/sdj
brw-r----- 1 root disk 8, 145 Apr 30 09:53 /dev/sdj1
brw-r----- 1 root disk 8, 146 Apr 30 09:53 /dev/sdj2
brw-r----- 1 root disk 8, 147 Apr 30 09:53 /dev/sdj3
brw-r----- 1 root disk 8, 148 Apr 30 09:53 /dev/sdj4
brw-r----- 1 root disk 8, 149 Apr 30 09:53 /dev/sdj5
brw-r----- 1 root disk 8, 150 Apr 30 09:53 /dev/sdj6
brw-r----- 1 root disk 8, 151 Apr 30 09:53 /dev/sdj7
brw-r----- 1 root disk 8, 152 Apr 30 09:53 /dev/sdj8
brw-r----- 1 root disk 8, 153 Apr 30 09:53 /dev/sdj9

 

As shown above, we can judge that disk 9 corresponds to / dev/sdj under Linux through the output information of the above command.

Topics: Linux Vmware CentOS Mac