VMware虚拟机(Linux)中,我们的Linux服务器可能拥有多个磁盘(或者叫虚拟磁盘),如下所示,这个服务器的磁盘有硬盘1、硬盘2、…………硬盘10总共10块硬盘。
而Linux系统中,磁盘中对应的设备如下
[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
那么我们如何找出/dev/sdj对应VMware中的哪个磁盘呢? 相信很多同学可能想通过磁盘大小来判断,但是呢,这个通过磁盘大小不好判断或者判断不精准,主要有下面一些因素:
1:两边计算磁盘大小的方式不一样。看到的磁盘大小有点出入。
2:可能存在相同大小的磁盘,此时你怎么判断呢?
那么有没有通过某个标识来判断呢?根据SCSI标准,每个SCSI磁盘都有一个WWID,类似于网卡的MAC地址,而且是独一无二。Linux系统上/dev/disk/by-id目录包含每个SCSI磁盘WWID访问路径。
[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
但是当前环境下,VMware虚拟机(Linux)默认情况下没有开启这个选项。
# 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
而且在VMware vSphere Client连上VMware控制台,你会发现这里没有提供硬盘的WWID信息,即使你在Linux中找到设备的WWID信息,但是在VMware控制台也看不到对应的WWID信息,我们还可以通过计算机的SCSI编号来判断,SCSI 可适用于许多设备(包括随机存取设备,比如磁盘和像磁带这样的顺序存储设备),如下截图所示,磁盘有个显示是通过SCSI控制器管理磁盘的,硬盘9对应的为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
如上所示,我们通过上面命令的输出信息就可以判断磁盘9对应Linux下的/dev/sdj这个设备。