修复ESXi的快照混乱问题

注意:本文最后更新于 2752 天前,有关的内容可能已经发生变化,请参考使用。

母系统为ESXi 3.5的服务器,上面有一台FreeBSD的客户机,不知因为什么原因上面的十一个快照紊乱了,记得以前强行删除所有快照的时候可能会遇到这个情况。明白问题状态之后第一时间将客户机关闭,打开ESXi的命令行控制台,相应的文件夹内有FreeBSD8.vmdk,FreeBSD8-0000xx.vmdk等文件,FreeBSD8.vmdk为镜像之前最基本的硬盘,FreeBSD8-0000xx.vmdk是每个快照之后的硬盘镜像。

这是在等PORTS更新和编译的事件中匆匆写的,有些混乱。


网上关于ESXi下虚拟硬盘损坏该怎么修复的相关文档比较少,幸好找到了一篇跟今天遇到的情况类似的文章,很勉强地将出问题的硬盘恢复到了第八个快照,9、10、11快照都挂掉了,大概过程如下:

首先大概看一下虚拟硬盘和快照的配置文件

    cat FreeBSD8.vmdk
    # Disk DescriptorFile
    version=1
    CID=ca6e491c
    parentCID=ffffffff
    createType="vmfs"
    # Extent description
    RW 52428800 VMFS "FreeBSD8-flat.vmdk"
     
    # The Disk Data Base
    #DDB
     
    ddb.toolsVersion = "0"
    ddb.adapterType = "lsilogic"
    ddb.geometry.sectors = "63"
    ddb.geometry.heads = "255"
    ddb.geometry.cylinders = "3263"
    ddb.uuid = "60 00 C2 97 58 8b 85 4b-0d 26 c1 0d 18 6f 30 99"
    ddb.virtualHWVersion = "4"
    cat FreeBSD8.vmdk
    # Disk DescriptorFile
    version=1
    CID=ca6e491c
    parentCID=ffffffff
    createType="vmfs"
    
    # Extent description
    RW 52428800 VMFS "FreeBSD8-flat.vmdk"
    
    # The Disk Data Base
    #DDB
    
    ddb.toolsVersion = "0"
    ddb.adapterType = "lsilogic"
    ddb.geometry.sectors = "63"
    ddb.geometry.heads = "255"
    ddb.geometry.cylinders = "3263"
    ddb.uuid = "60 00 C2 97 58 8b 85 4b-0d 26 c1 0d 18 6f 30 99"
    ddb.virtualHWVersion = "4"

这是基本的硬盘,没有什么问题,可以挂上到虚拟机中直接运行,但是硬盘里面的内容都是相当老的(就是第一次做快照之前的)


    vmkfstools -i FreeBSD8-000011.vmdk recover/newFB8.vmdk
    /vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeBSD8-000011.vmdk recover/newFB8.vmdk
    Destination disk format: VMFS thick
    Failed to open 'FreeBSD8-000011.vmdk': The parent virtual disk has been modified since the child was created (18).
    vmkfstools -i FreeBSD8-000011.vmdk recover/newFB8.vmdk
    /vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeBSD8-000011.vmdk recover/newFB8.vmdk
    Destination disk format: VMFS thick
    Failed to open 'FreeBSD8-000011.vmdk': The parent virtual disk has been modified since the child was created (18).

如果不将所有的依赖修复正确的话就会出现上面的错误提示:The parent virtual disk has been modified since the child was created (18).


    cat FreeBSD8-000001.vmdk
    # Disk DescriptorFile
    version=1
    CID=fe461459
    parentCID=77039591 //这里开始出问题了
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000001-delta.vmdk"
     
    # The Disk Data Base
    #DDB
     
    ddb.toolsVersion = "0"
    ----------------------------------------------------------------------
    cat FreeBSD8-000002.vmdk
    # Disk DescriptorFile
    version=1
    CID=004ed653
    parentCID=fe461459
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8-000001.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000002-delta.vmdk"
     
    # The Disk Data Base
    #DDB
    ddb.toolsVersion = "0"
    ----------------------------------------------------------------------
    cat FreeBSD8-000003.vmdk
    # Disk DescriptorFile
    version=1
    CID=1d8809e0
    parentCID=004ed653
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8-000002.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000003-delta.vmdk"
     
    # The Disk Data Base
    #DDB
     
    ddb.toolsVersion = "0"
    …………
    ----------------------------------------------------------------------
    cat FreeBSD8-000009.vmdk
    # Disk DescriptorFile
    version=1
    CID=997874b0
    parentCID=6bc1e139
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8-000008.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000009-delta.vmdk"
     
    # The Disk Data Base
    #DDB
     
    ddb.toolsVersion = "0"
    cat FreeBSD8-000001.vmdk
    # Disk DescriptorFile
    version=1
    CID=fe461459
    parentCID=77039591     //这里开始出问题了
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000001-delta.vmdk"
    
    # The Disk Data Base
    #DDB
    
    ddb.toolsVersion = "0"
    ----------------------------------------------------------------------
    cat FreeBSD8-000002.vmdk
    # Disk DescriptorFile
    version=1
    CID=004ed653
    parentCID=fe461459
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8-000001.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000002-delta.vmdk"
    
    # The Disk Data Base
    #DDB
    ddb.toolsVersion = "0"
    ----------------------------------------------------------------------
    cat FreeBSD8-000003.vmdk
    # Disk DescriptorFile
    version=1
    CID=1d8809e0
    parentCID=004ed653
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8-000002.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000003-delta.vmdk"
    
    # The Disk Data Base
    #DDB
    
    ddb.toolsVersion = "0"
    …………
    ----------------------------------------------------------------------
     cat FreeBSD8-000009.vmdk
    # Disk DescriptorFile
    version=1
    CID=997874b0
    parentCID=6bc1e139
    createType="vmfsSparse"
    parentFileNameHint="FreeBSD8-000008.vmdk"
    # Extent description
    RW 52428800 VMFSSPARSE "FreeBSD8-000009-delta.vmdk"
    
    # The Disk Data Base
    #DDB
    
    ddb.toolsVersion = "0"

简单的看了一下所有快照镜像的配置文件发现:1-11个快照镜像中间缺了三个依赖,FreeBSD8-000001.vmdk的父盘CID错误。考虑到要最大恢复到最近的磁盘数据于是打算先将FreeBSD8-000001.vmdk的父盘CID更正,再用vmkfstools将快照镜像和虚拟原盘合并拷贝成一个新磁盘。


    /vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeBSD8-000011.vmdk recover/newFB8.vmdk
    Destination disk format: VMFS thick
    Cloning disk 'FreeBSD8-000011.vmdk'...
    Clone: 5% done.Failed to clone disk : Read beyond the end of file (2311).
    /vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeBSD8-000011.vmdk recover/newFB8.vmdk
    Destination disk format: VMFS thick
    Cloning disk 'FreeBSD8-000011.vmdk'...
    Clone: 5% done.Failed to clone disk : Read beyond the end of file (2311).

无奈最新的一个快照镜像在5%的时候就挂掉了,报错2311,超过了文件的大小,想了不少办法并做了很多尝试无效之后偶然发现了这个帖子,虽然情况类似但是稍微靠谱一点的回答只有最后那一个


    For me, the problem was that the block count for the drive (RW number in .vmdk file) didn't match the actual size of the -flat.vmdk file.
    Power off the Virtual Machine.
    In Service Console, do ls -l to see the size of the machinename+-flat.vmdk+ file. Divide the value by 512. The result should be the RW number which goes into machinename+.vmdk+ file. Don't change the geometry parameters in the .vmdk file !!
    Try vmkfstools -i now, should besuccessfull now.
    Do necessary changes you want in the Properties of the Virtual Machine (or edit .vmx file directly)
    Power on the Virtual Machine
    For me, the problem was that the block count for the drive (RW number in .vmdk file) didn't match the actual size of the -flat.vmdk file. 
    Power off the Virtual Machine. 
    In Service Console, do ls -l to see the size of the machinename+-flat.vmdk+ file. Divide the value by 512. The result should be the RW number which goes into machinename+.vmdk+ file. Don't change the geometry parameters in the .vmdk file !!
    Try vmkfstools -i now, should besuccessfull now.
    Do necessary changes you want in the Properties of the Virtual Machine (or edit .vmx file directly) 
    Power on the Virtual Machine

但是经排查不是因为错误的大小导致的,所以只能放弃使用老一版本的快照。

 

    /vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeBSD8-000010.vmdk recover/newFB8-10.vmdk
    Destination disk format: VMFS thick
    Cloning disk 'FreeBSD8-000010.vmdk'...
    Clone: 23% done.Failed to clone disk : Input/output error (327689).
    /vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeBSD8-000010.vmdk recover/newFB8-10.vmdk
    Destination disk format: VMFS thick
    Cloning disk 'FreeBSD8-000010.vmdk'...
    Clone: 23% done.Failed to clone disk : Input/output error (327689).

使用第十个快照镜像恢复的时候出现了如上的Input/output error (327689).错误,这是很明显的I/O错误,估计要恢复的可能性不大,而且即使可行过程也会相对麻烦,于是只能忍痛到更老的版本……

/vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeB SD8.vmdk recover/newsysdisk.vmdk
Destination disk format: VMFS thick
Cloning disk 'FreeBSD8.vmdk'...
Clone: 92% done.
/vmfs/volumes/4c4b73b2-7bd2fabc-31ce-00188b48fd66/FreeBSD8 # vmkfstools -i FreeB                                             SD8.vmdk recover/newsysdisk.vmdk
Destination disk format: VMFS thick
Cloning disk 'FreeBSD8.vmdk'...
Clone: 92% done.

同样的IO错误直到第8个才成功还原一个完成的虚拟硬盘,挂上系统之后发现硬盘上的内容是一个月前的,还好其他的重要数据磁盘和日志磁盘使用的是独立模式,不依赖于快照的虚拟磁盘,这次被ESXi的快照功能伤的很深……

不推荐使用ESXi的快照功能:
一是带快照的ESXi客户机系统会严重的降低性能(主要原因是原来是定长的虚拟硬盘文件变为了动长);
二是莫名其妙容易出现快照紊乱,尤其是十几个快照之后稍微有维护者出错的话后果不堪设想。


PS:进入ESXi的命令行的方法,按Alt-F1(切换控制台)、输入“unsupported”(无回显内容),然后点回车键,就可以激活本地控制台提示符。之后再需要输入root密码,接着就可以进入ESXi主机的本地控制台界面


「倘若有所帮助,不妨酌情赞赏!」

Holmesian

感谢您的支持!

使用微信扫描二维码完成支付


相关文章

发表新评论
暂无评论
  1. 小说库

    http://www.seomimic.com/成都SEO表示很关注你的博客,并且希望能和博主交换友情链接

    小说库 回复