找不到文件vmdk虚拟磁盘

benico 2020-08-19

找不到文件vmdk虚拟磁盘

问题:在迁移虚拟机之后,启动找不到虚拟磁盘vmdk文件,虚拟机无法启动
修复:

1,首先开启vSphere client的SSH端口

配置--安全配置文件--服务-属性-SSH-选项-启动

2,找到虚拟机损坏虚拟机所在位置

find / -name "*172.16.2.12"
cd /vmfs/volumes/5df3037a-d30a045c-62a0-0894ef4fa40c/linux-172.16.2.12

3,查看

ls -l 
-rw-------    1 root     root     42949672960  Aug 14 13:59 linux-172.16.2.12-flat.vmdk
-rw-------    1 root     root          8684    Aug 15 01:13 linux-172.16.2.12.nvram
-rw-------    1 root     root             0    Aug 14 13:43 linux-172.16.2.12.vmsd
-rw-------    1 root     root          3021    Aug 14 15:42 linux-172.16.2.12.vmx
-rw-------    1 root     root     214748364800 Aug 14 14:37 linux-172.16.2.12_1-flat.vmdk
-rw-------    1 root     root     214748364800 Aug 14 12:19 linux-172.16.2.12_2-flat.vmdk
-rw-------    1 root     root           483    Jun 12 08:38 linux-172.16.2.12_2.vmdk

#可以看到只有linux-172.16.2.12_2.vmdk有指向磁盘的文件,
#其他两个磁盘找不到的原因就是没有对应的linux-172.16.2.12.vmdk,linux-172.16.2.12_1.vmdk文件

4,修复

#创建linux-172.16.2.12.vmdk,linux-172.16.2.12_1.vmdk
#需要创建虚拟磁盘,首先创建两个和有问题的两个磁盘大小一致的磁盘
vmkfstools -c 42949672960 -a lsilogic  cipan1.vmdk
#cipan1.vmdk对应linux-172.16.2.12.vmdk
vmkfstools -c 214748364800 -a lsilogic  cipan2.vmdk
#cipan2.vmdk对应linux-172.16.2.12_1.vmdk
#重命名cipan1.vmdk为linux-172.16.2.12.vmdk
mv cipan1.vmdk linux-172.16.2.12.vmdk
#重命名cipan2.vmdk为linux-172.16.2.12_1.vmdk
mv cipan2.vmdk linux-172.16.2.12_1.vmdk

ls -l 
-rw-------    1 root     root     42949672960 Aug 17 02:10 linux-172.16.2.12-flat.vmdk
-rw-------    1 root     root          8684 Aug 17 02:24 linux-172.16.2.12.nvram
-rw-------    1 root     root           479 Aug 17 02:08 linux-172.16.2.12.vmdk
-rw-------    1 root     root          3000 Aug 17 02:10 linux-172.16.2.12.vmx
-rw-------    1 root     root     214748364800 Aug 17 02:09 linux-172.16.2.12_1-flat.vmdk
-rw-------    1 root     root           483 Aug 17 02:08 linux-172.16.2.12_1.vmdk
-rw-------    1 root     root     214748364800 Aug 17 02:10 linux-172.16.2.12_2-flat.vmdk
-rw-------    1 root     root           483 Aug 17 02:08 linux-172.16.2.12_2.vmdk

#可以看到对应的**-flat.vmdk都有**.vmdk文件了,但是此时**.vmdk文件中指定的**.flat.vmdk还是创建时候的cipan1/2-flat.vmdk,需要修改过来

5,修改

## 注意RW 83886080 VMFS "linux-172.16.2.12-flat.vmdk",这一行是修改后的内容
vi linux-172.16.2.12.vmdk

      # Disk DescriptorFile
      version=1
      encoding="UTF-8"
      CID=8226dd02
      parentCID=ffffffff
      isNativeSnapshot="no"
      createType="vmfs"

      # Extent description
      RW 83886080 VMFS "linux-172.16.2.12-flat.vmdk"

      # The Disk Data Base
      #DDB

      ddb.adapterType = "lsilogic"
      ddb.geometry.cylinders = "5221"
      ddb.geometry.heads = "255"
      ddb.geometry.sectors = "63"
      ddb.longContentID = "6dd446f4d6cc3e5a04d32c728226dd02"
      ddb.uuid = "60 00 C2 9a 12 fe 85 5d-11 3e 54 e1 e3 cd 98 69"
      ddb.virtualHWVersion = "11"

vi linux-172.16.2.12_1.vmdk
      # Disk DescriptorFile
      version=1
      encoding="UTF-8"
      CID=df194f9c
      parentCID=ffffffff
      isNativeSnapshot="no"
      createType="vmfs"

      # Extent description
      RW 419430400 VMFS "linux-172.16.2.12_1-flat.vmdk"

      # The Disk Data Base
      #DDB

      ddb.adapterType = "lsilogic"
      ddb.geometry.cylinders = "26108"
      ddb.geometry.heads = "255"
      ddb.geometry.sectors = "63"
      ddb.longContentID = "a87db942cad1c41970236d93df194f9c"
      ddb.uuid = "60 00 C2 97 be 1f d3 28-01 ec 22 e2 a9 7b a6 9e"
      ddb.virtualHWVersion = "11"

6,遇到错误failed to lock the file

# 方法就是在linux-172.16.2.12.vmx文件最后一行加入
disk.locking = "FALSE"

重启虚拟机,一切正常

相关推荐