Virtualbox 的VM image size (.vdi file)有时候会变得很大, 如何缩减文件大小呢?
这里我的host = MacBook Pro, guest = Win7. 虚拟机创建的时候设置的是 “Dynamically Expanding Storage” , 但以后随着增删文件操作而磁盘只会增加不会减少。
- Run defrag in the guest (Windows only)
- Nullify free space:With a Linux Guest run this:
sudo dd if=/dev/zero of=/bigemptyfile bs=4096k sudo rm -rf /bigemptyfile
With a Windows Guest, download SDelete from Sysinternals and run this:sdelete –z c:
- Shutdown the guest VM
- Now run VBoxManage's
modifyhd
command with the--compact
option:With a Linux Host run this:vboxmanage modifyhd /path/to/thedisk.vdi --compact
With a Windows Host run this:VBoxManage.exe modifyhd c:\path\to\thedisk.vdi --compact
With a Mac Host run this:VBoxManage modifyhd /path/to/thedisk.vdi --compact
This reduces the vdi size.
没有评论:
发表评论