VMware虛擬機(Linux)中,我們的Linux伺服器可能擁有多個磁碟(或者叫虛擬磁碟),如下所示,這個伺服器的磁碟有硬碟1、硬碟2、…………硬碟10總共10塊硬碟。 而Linux系統中,磁碟中對應的設備如下 [root@mylnx01 ~]# ls -lrt /dev/sd*brw-r----... ...
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這個設備。