본문 바로가기
카테고리 없음

virtualbox vdi 사이즈 축소 방법

by Knowledge Store In Hyunsoft 2018. 8. 15.

VirtualBox sparse VDI images always take up as much space as they have maximally had utilized at some point in time. To fix this, we need to fill the empty space on the vdi with zeros and resize it:

Download the SystemRescueCd Live Image.

Mount it as a CD on your virtual machine and boot into the live distro.

Open up a Root Terminal.

Find all available partition and LVM (volume groups) with:

1
fdisk -l

After we find our partition run zerofree to zero out the free space. In our example we will run it on the LVM root partition.

1
zerofree -v /dev/mapper/vg_rheldev-lv_root

If you want to try a dry run without modifying the hard-drive, add the -n flag.
For LVM, there might also be a _home partition that needs a zerofree run as well.

Finally, boot down your virtual machine, and run VBoxManage on the host to resize the .vdi file.

1
VBoxManage.exe modifyhd --compact "C:\Users\k\VMs\CentOS Dev.vdi"

(Example is on a Windows host. Linux command should look the same, just omit .exe and add in the correct path.)

 

 

 

 

 

 

 

XFS 파티션

 

Step 2: Clean any free disk space

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:

dd if=/dev/zero of=zerofillfile bs=1M

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

Once the dd has completed, you will see a message in your terminal window indicating that there is no space left on the device:

dd: writing 'zerofillfile': No space left on device

You can now remove zerofillfile using the Linux rm utility:

rm zerofillfile

Step 3: Shutdown the 

VBoxManage.exe modifyhd --compact "C:\Users\k\VMs\CentOS Dev.vdi"
728x90

댓글