情境: 原本使用vSphere 5.1好好的,沒有移除vSphere就直接更新,更新成vSphere 5.1 update版本後,由於有一台VM使用的是本機的Local Datastore,而非網路儲存設備(如: iSCSI or NFS)。導致更新成vSphere 5.1 update後,VM存放目錄裡的.vmdk檔移失了,而多了個-flat.vmdk檔,使得VM開不起來。這裡就教如何將移失的.vmdk找回來。

1. 先至vSphere啟動SSH Service.

 

2. 用ssh登入vSphere

 

3. 進入vSphere local datastore目錄
~ # cd /vmfs/volumes/datastore/

 

4. 共有三個目錄,分別為VM:DNS, DHCP, and Web,我們的範例以Web_VM來作試範。
/vmfs/volumes/datastore # ls
------------------------------------------
DNS_VM
DHCP_VM
Web_VM
------------------------------------------

 

5. 進入Web_VM這個目錄
/vmfs/volumes/datastore # cd Web_VM/

 

6. 查看原始的Web_VM.vmdk是否真的不見了。但此時只看到Web_VM-flat.vmdk
/vmfs/volumes/datastore/Web_VM # ls -ltr *.vmdk
------------------------------------------
-rw-------  1 root root  70866960384 Aug 15 02:12 Web_VM-flat.vmdk
------------------------------------------

 

7. 查看.vmx檔裡的scsi0.virtualDev是否為"lsilogic"
/vmfs/volumes/datastore/Web_VM # less *.vmx|grep virtualdev
------------------------------------------
pciBridge4.virtualDev = "pcieRootPort"
pciBridge5.virtualDev = "pcieRootPort"
pciBridge6.virtualDev = "pcieRootPort"
pciBridge7.virtualDev = "pcieRootPort"
scsi0.virtualDev = "lsilogic"
ethernet0.virtualDev = "e1000"
------------------------------------------

 

8. 查看vmdk的容量資訊,並將其複製(此為70866960384)
/vmfs/volumes/datastore/Web_VM # ls -l *-flat.vmdk
------------------------------------------
-rw-------  1 root root  70866960384 Aug 15 02:12 Web_VM-flat.vmdk
------------------------------------------

 

9. 建立一個暫存的.vmdk索引(容量很小)
/vmfs/volumes/datastore/Web_VM # vmkfstools -c 70866960384 -a lsilogic -d thin temp.vmdk
------------------------------------------
Create: 100% done.
------------------------------------------

 

10. 再度查看vmdk的容量資訊,此時看到多了兩個檔案,一個是索引檔,也就是temp.vmdk
/vmfs/volumes/datastore/Web_VM # ls -ltr *.vmdk
------------------------------------------
-rw-------  1 root root  70866960384 Aug 15 02:12 Web_VM-flat.vmdk
-rw-------  1 root root  70866960384 Aug 15 05:36 temp-flat.vmdk
-rw-------  1 root root      492 Aug 15 05:36 temp.vmdk
------------------------------------------

 

11. 將temp.vmdk更改名稱為我們所移失的Web_VM.vmdk
/vmfs/volumes/datastore/Web_VM # mv temp.vmdk Web_VM.vmdk

 

12. 再度查看,更改檔名後的結果
/vmfs/volumes/datastore/Web_VM # ls -ltr *.vmdk
------------------------------------------
-rw-------  1 root root  70866960384 Aug 15 02:12 Web_VM-flat.vmdk
-rw-------  1 root root  70866960384 Aug 15 05:36 temp-flat.vmdk
-rw-------  1 root root      492 Aug 15 05:36 Web_VM.vmdk
------------------------------------------

 

13. 修改Web_VM.vmdk索引檔,將temp-flat.vmdk改成Web_VM-flat.vmdk
/vmfs/volumes/datastore/Web_VM # vi Web_VM.vmdk
------------------------------------------
# Disk DescriptorFile
version=1
encoding="UTF-8"
CID=fffffffe
parentCID=ffffffff
isNativeSnapshot="no"
createType="vmfs"

# Extent description
#RW 138412032 VMFS "temp-flat.vmdk"
RW 138412032 VMFS "Web_VM-flat.vmdk"

# The Disk Data Base
#DDB

ddb.virtualHWVersion = "9"
ddb.longContentID = "d697091cdd0a56427ed399b2fffffffe"
ddb.uuid = "60 00 C2 90 42 22 d5 8f-50 d8 11 7f 9c cd ec 7b"
ddb.geometry.cylinders = "8615"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.thinProvisioned = "1"
ddb.adapterType = "lsilogic"
~
------------------------------------------


14. 這樣就大功告成了!
/vmfs/volumes/datastore/Web_VM # ls
------------------------------------------
Web_VM-flat.vmdk
Web_VM.vmdk
temp-flat.vmdk
------------------------------------------

 

15. 接下來就是去測試把Web_VM給開啟的喜悅吧^^

 

以上參考資料出自: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002511

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dreamtails 的頭像
    dreamtails

    雜七雜八的小筆記!

    dreamtails 發表在 痞客邦 留言(2) 人氣()