virtualbox压缩vdi硬盘

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 20:17 点击:

virtualbox压缩vdi硬盘
 
今天清理了guest系统之后,发现应该压缩一下虚拟硬盘,在网上找了了一下,都是用 vboxmanage 工具,然而照做下来,就是不成功。
最后找了了官方文档,才发现原因。
 
首先,看 vbox的官方文档:
http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi
 
VBoxManage modifyhd         <uuid>|<filename>
                            [--type normal|writethrough|immutable|shareable|
                                    readonly|multiattach]
                            [--autoreset on|off]
                            [--compact]
                            [--resize <megabytes>|--resizebyte <bytes>]
With the --compact option, can be used to compact disk images, i.e. remove blocks that only contains zeroes. This will shrink a dynamically allocated image again; it will reduce the physical size of the image without affecting the logical size of the virtual disk. Compaction works both for base images and for diff images created as part of a snapshot.  www.2cto.com  
For this operation to be effective, it is required that free space in the guest system first be zeroed out using a suitable software tool. For Windows guests, you can use the sdelete tool provided by Microsoft. Execute sdelete -z in the guest to zero the free disk space before compressing the virtual disk image. For Linux, use the zerofree utility which supports ext2/ext3 filesystems.
Please note that compacting is currently only available for VDI images. A similar effect can be achieved by zeroing out free blocks and then cloning the disk to any other dynamically allocated format. You can use this workaround until compacting is also supported for disk formats other than VDI.
关键之处正在于 sdelete 应该使用 -z 选项 ,而网上所以的方法都说是使用 -c 选项,这个浪费了近3个小时。
 
MS的文档也说的明白:
http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx
 
Using SDelete
SDelete is a command line utility that takes a number of options. In any given use, it allows you to delete one or more files and/or directories, or to cleanse the free space on a logical disk. SDelete accepts wild card characters as part of the directory or file specifier.  www.2cto.com  
usage: sdelete [-p passes] [-s] [-q] <file or directory> ...
       sdelete [-p passes] [-z|-c] [drive letter] ...
   -a         Remove Read-Only attribute
   -c         Clean free space
   -p passes  Specifies number of overwrite passes (default is 1)
   -q         Don't print errors (Quiet)
   -s or -r   Recurse subdirectories
   -z         Zero free space (good for virtual disk optimization)
 
所以,总结一下,正确的方法应该是这样:
1,  在guest os 中清理系统, windows的话可以再硬盘碎片整理一下 
2,  在 guest os 中 使用 sdelete -z  ; linux 使用 zerofree
3,  VBoxManage modifyhd <uuid>|<filename>  --compact
 
 
作者 bbplayers
    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • VMware View 5.0从菜鸟到高手系列 -连接虚拟桌面
    • kvm中的windows使用Vmware的显示驱动
    • VMware Linux使用Xshell登陆
    • 虚拟机安装MAC查看电脑CPU是否支持VT技术
    • VMWare NAT Centos6.2静态ip设置
    • 给虚拟机提速的方法
    • vmware虚拟机浅析-虚拟网卡
    • VirtualBox打开虚拟硬盘失败的问题
    • Virtual Box下同时配置host-only和bridge

    快速直达

    操作系统导航

    LinuxWindows虚拟机
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1