When using a Ubuntu virtual box guest, sometimes we want to shrink the dynamic expanding VDI file to release the unused disk space. Here is the steps to archive that.
Install ZeroFree
sudo apt-get install zerofree
Reboot into recovery mode
a.sudo shutdown -r now
b. Holding the left Shift key while rebooting
c. Select Advanced and then Recovery mode and finally Drop to root shell prompt option.Remount the root partition
mount -n -o remount,ro -t ext4 /dev/sda1 /
Run ZeroFree
sudo zerofree -v /dev/sda1
Shutdown the VM
shutdown -h now
Shrink the VDI file is host OS
SET PATH=%PATH%;"c:\Program Files\Oracle\VirtualBox VBoxManage modifyhd Ubuntu.vdi -compact
Reference: How to shrink a dynamically-expanding guest virtualbox image
No comments:
Post a Comment