如果使用vhd中一不小心断电了,vhd就报错.
提示无法装载,文件或目录损坏!
gogo好久找到一个死链:
http://code.msdn.microsoft.com/vhdtool
受不了
然后又找到了:vhdxtool
http://systola.com/support/KB100005
结果都没有修复功能.
又找到一个:
https://web.archive.org/web/20130504064711/http://archive.msdn.microsoft.com/vhdtool/Release/ProjectReleases.aspx?ReleaseId=5344
结果不能下载.
还找到了这个:
https://blog.workinghardinit.work/tag/vhd-tool/
结果没有修复功能
5小时:
又上github
https://github.com/andreiw/vhdtool
可惜根本不是我需要的哪个版本.只是同名而已
.
6小时:
最后终于找到了:
http://www.mediafire.com/download/f96bmsvjz4qdvbu/VhdTool.zip
版本为2.0,大小为58K(gogo: vhdtool 2.0 )
Create: Creates a new fixed format VHD of size .
WARNING - this function is admin only and bypasses
file system security. The resulting VHD file will
contain data which currently exists on the physical disk.
Convert: Converts an existing file to a fixed-format VHD.
The existing file length, rounded up, will contain block data
A VHD footer is appended to the current end of file.
Extend: Extends an existing fixed format VHD to a larger size .
WARNING - this function is admin only and bypasses
file system security. The resulting VHD file will
contain data which currently exists on the physical disk.
Repair: Repairs a broken Hyper-V snapshot chain where an administrator
has expanded the size of the root VHD. The base VHD will be
returned to its original size. THIS MAY CAUSE DATA LOSS if the
contents of the base VHD were changed after expansion.
然后 repair
然后我还上传了百度盘,有需要的哪去,可惜没有找到源代码:
http://pan.baidu.com/s/1qY25NrQ
由于我没有avhd(备份文件所以这个办法行不通)
7 结果
研究了好久,发现损坏的vhd可以用diskgenius打开,可以读出文件!
说明vhd只是ntfs系统不完整.
其实只要chkdsk一下就可以了.但是chkdsk不支持虚拟磁盘!!
猜想:
还可以上终极大法!
安装virtualBox,把vhd文件当硬盘镜像!然后进入虚拟机chkdsk!
可惜它读取vhd不像虚拟光驱一样直接读取的,会报错.不能加载.
还可以用hyper-v方式来处理,参考:
http://www.techieshelp.com/hyper-v-vhd-the-file-or-directory-is-corrupted-and-unreadable/
8 另外的
还有通过程序来解决
vb和C#/vbs都可以连接系统硬件挂载服务
如下连接:
https://msdn.microsoft.com/zh-cn/library/cc136982(v=vs.85).aspx
9 用脚本来解决
比较方便的是用脚本来解决: (powsershell)
$VHDName = "V:\serverx.vhd"
#Get the MSVM_ImageManagementService
$VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization" -computername "."
#Now we mount the VHD
$Result = $VHDService.Mount($VHDName)
chkdsk
只能在windows server 2008上这样操作.(要安装 hyper-V管理工具:关闭或打开windows功能 )
注:windows sever 2008以后 namespace有v2 (win10上成功, win7 没有hyper-v管理工具)
相应的命令要改成: Get-WmiObject -computername "." -namespace "root\virtualization\v2" -class "Msvm_ImageManagementService"
还是万能的stackoverflow强大.
http://stackoverflow.com/questions/tagged/vhd
10 回到起点
windows系统支持虚拟硬盘. 所以" 虚拟硬盘软件工具"很少,不像虚拟光驱一大把.
https://social.technet.microsoft.com/Forums/windowsserver/en-US/a08ad18f-4b6a-46a0-bd1f-274fbbc5b737/attach-a-vhd-in-windows-7
用diskpart attach abc.vhd
然后 chkdsk