重建丢失/损坏的 VMware 虚拟机磁盘描述符文件 (.vmdk)
遇到问题:
在 VMware vSphere Client 中,收到如下错误信息:
Cannot open the disk '/vmfs/volumes/.../VM_NAME/VM_NAME.vmdk' or one of the snapshot disks it depends on. Reason: The file specified is not a virtual disk.
在 vmware.log 文件中,也会看到类似的条目:
vmx| I120: DISKLIB-LINK : "/vmfs/volumes/57159965-bab73b05-fec7-3863bb45d158/VM_NAME/VM_NAME.vmdk" : failed to open (The file specified is not a virtual disk).
vmx| I120: DISKLIB-CHAIN : "/vmfs/volumes/57159965-bab73b05-fec7-3863bb45d158/VM_NAME/VM_NAME.vmdk" : failed to open (The file specified is not a virtual disk).
vmx| I120: DISKLIB-LIB : Failed to open '/vmfs/volumes/57159965-bab73b05-fec7-3863bb45d158/VM_NAME/VM_NAME.vmdk' with flags 0xa The file specified is not a virtual disk (15).
vmx| I120: DISK: Cannot open disk "/vmfs/volumes/57159965-bab73b05-fec7-3863bb45d158/VM_NAME/VM_NAME.vmdk": The file specified is not a virtual disk (15).
解决办法:
cd /vmfs/volumes/DATASTORE_NAME/VM_NAME
ls -ahl
# Identify the SCSI controller type in use by the virtual disk
less *.vmx | grep -i virtualdev
pciBridge4.virtualDev = "pcieRootPort"
pciBridge5.virtualDev = "pcieRootPort"
pciBridge6.virtualDev = "pcieRootPort"
pciBridge7.virtualDev = "pcieRootPort"
scsi0.virtualDev = "lsisas1068" <---
ethernet0.virtualDev = "e1000e"
# Identify the exact size of the flat.vmdk file
ls -l VM_NAME-flat.vmdk
-rw------- 1 root root 85899345920 <--- VM_NAME-flat.vmdk
# Use the `vmkfstools` command to create a temporary descriptor file (.vmdk)
# and an associated temporary flat file (flat.vmdk)
# vmkfstools -c <VM_NAME-flat.vmdk file_size> -a <scsi_type> -d thin <temp_filename>.vmdk
vmkfstools -c 85899345920 -a lsisas1068 -d thin temp.vmdk
ls -ahl
mv temp.vmdk VM_NAME-000001.vmdk
# Edit the descriptor (.vmdk) file to point to the correct -flat.vmdk file
vi VM_NAME-000001.vmdk
replace "temp-flat.vmdk" -> "VM_NAME-000001-flat.vmdk"
# If the original vm disk was not thin provisioned then we need to remove the following line
ddb.thinProvisioned = "1"
# Delete the temporary flat.vmdk file
rm -i temp-flat.vmdk
# Check the disk chain consistency
vmkfstools -e VM_NAME-000001.vmdk
Disk chain is consistent.
References:
看看别滴