Virtualbox compressed virtual hard disk

Source: Internet
Author: User

Virtralbox uses a VDI file to provide a virtual hard disk for the Virtual Machine. during use, this file grows more than actually used, for example, in a Virtual Machine, the operating system may have only 2 GB space for other files, but the virtual hard disk file may have 5 GB space in the host machine, and the most important thing is that even if the file is deleted from the virtual machine, it will not be reflected in the VDI file. That is to say, this file will not become smaller and will only grow bigger. If you have many virtual machines or frequently install and uninstall software, this is a big problem, so virtualbox provides a method to compress VDI files. Unfortunately, this method is not integrated into the graphic management interface and cannot be completed in one step. The following two steps are required. (It is best to back up the virtual hard disk VDI file before you start .)

1. Prepare a disk for compression on the client (Virtual Machine)

For Windows systemsFirst, delete unnecessary and temporary files in the disk or partition to be compressed, and sort out the disk.

Then we use an sdelete tool to prepare disk partitions (sdelete is Microsoft's secure deletion tool, which can be searched and downloaded from the internet). After downloading it, enter the following in the doscommand window:

Sdelete-C(Copy sdetele to the partition to be processed.-C indicates the database that uses 0 to fill in the deleted files. The virtual disk tool can process and compress virtual hard disk files)

For LinuxTo download and install a zerofree tool, you must enter the init.1 mode and use the following command:

Download and install the zerofree command:

Sudo apt-Get install zerofree

Enter the init.1 mode command:

Sudo init 1

To remount the hard disk in read-only mode, run the following command:

Mount-n-o remount, ro-T ext4/dev/sdb1/var

Command for compressing mounted hard disks:

Zerofree/dev/sdb1

Shut down the VM immediately after processing.

2. Use the vboxmanage command to compress virtual hard disk files on the host.

Use the following commands on the terminal to compress VDI files

Vboxmanage modifyhd/vdis/WINXP. VDI(Here, our VDI file is in/vdis and must be in the complete path)

Or it seems like this:

Vboxmanage clonehd/vdis/WINXP. VDI/winxp1.vdi(This method copies a VDI file, but the problem is that the file uses a new guid number and needs to be remounted.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.