Decrease VirtualBox images size
To help reduce excess disk usage, VirtualBox provides a mechanism for compacting dynamically allocated guest images. Below are the steps to follow if your guest operating system is Linux:
- Start the Linux virtual machine;
- Clean the free space on the disk of the Linux virtual machine;
- Shutdown the Linux virtual machine;
- Use the VirtualBox VBoxManage utility to compact the Linux guest image.
The most effective way to clean free disk space on a Linux drive is to use the Linux dd utility which is a bit-stream duplicator. Open up a terminal window and type the following command:
This command will zero-fill any free disk space on the virtual Linux drive.
- if= specifies the input file;
- /dev/zero indicates a bit-stream of zeros
- of= specifies the output file
- zerofillfile name of the file containing the bit-stream of zeros
- bs= indicates the block size
- 1M indicates that the block size will be 1 megabyte
You can now remove zerofillfile using the Linux rm utility:
Step 3: Shutdown the Linux Virtual Machine
End your session and shutdown the Linux Virtual Machine.
Step 4: Compact the Windows guest image
Assuming a Windows host, use the following command at the DOS prompt: