VirtualBox 收缩 vdi镜像文件

VirtualBox guest os用久了vdi文件就会越来越大,就算在guest os中删除了一些文件,vdi也不会变小。

如果guest os 是windows:

 

1、先在guest os上运行磁盘碎片管理器,将各个磁盘的磁盘碎片减少;

2、下载sdelete(http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx);

3、运行sdelete -c -z ;

4、关闭guest os 和 VirtualBox

5、在host os上运行VBoxManage modifyhd --compact yourImage.vdi

如果guest os 是Linux:

 

1、进入su

2、$ dd if=/dev/zero of=test.file

3、$ rm test.file

4、关闭guest os 和 VirtualBox

5、在host os上 运行 $ VBoxManage modifyhd --compact yourImage.vdi

这样在guest上看到占用的空间就和host上看到的空间就一样了。

作业环境:host os :Scientific Linux 6.1(X64)

                 guest os:Windows xp ,Scientific Linux 6.1(X64)

posted @ 2019-06-30 21:18  Thenext  阅读(966)  评论(0编辑  收藏  举报