Over the time, we can notice that the size of the dynamically growing virtual disks vdi file keep growing on Oracle Virtual box. Deleting the files inside the Guest Machine does not free up any space in the Host Machine's hard drive. We need to shrink vdi file to claim unused space.
Please follow the steps below to claim unused space.
We can notice that the size of the DGMaster.vdi is 20GB
Delete unnecessary files from the Guest machine.
Power off the guest machine.
Convert vdi file to compact.
VBoxManage modifyvdi DGMaster.vdi --compact
Power On the Guest Machine and install zero free package inside it.
We can get package from URL below. Package for EL5 works perfect for EL6 too.
http://rpm.pbone.net/index.php3/stat/4/idpl/15277264/dir/redhat_el_5/com/zerofree-1.0.1-5.el5.x86_64.rpm.html
Now umount the partition or make it read only. In my case I am freeing space from root partition so I need to reboot my Guest Machine to single user mode and make it read only.
Boot the system to single user mode
mount -o remount,ro /dev/mapper/vg_oel1-lv_root
Now find and fill unused, unallocated blocks with zero.
zerofree -v /dev/mapper/vg_oel1-lv_root
Output can be interpreted as: Total number of modified blocks/Total number of free blocks/Total number of blocks
Mount back the root partition to rw mode and poweroff the guest machine.
mount -o remount,rw /dev/mapper/vg_oel1-lv_root
poweroff
Now execute VBoxManage compact command from Host Machine to reclaim unused space. After modifyvdi completes you may notice the file size change.
VBoxManage modifyvdi DGMaster.vdi --compact
No comments:
Post a Comment