Tip: How to compact your virtual disks when using Linux guests

Discussion in 'Installation and Configuration of Parallels Desktop' started by ralphrmartin, Sep 11, 2008.

  1. ralphrmartin

    ralphrmartin Member

    Messages:
    58
    Here is a tip which might be helpful to people using Linux guest operating systems.

    Eventually, with use, your expanding virtual hard disk will grow quite a lot bigger than the amount of data on it. This is how to reduce the disk back down to a small size. There are 2 steps

    (1) Within Linux, you need to zero all free blocks. This can be done as follows:

    Install the "zerofree" package using whatever package manager is appropriate for your flavour of Linux.

    Boot your Linux VM in single user mode.
    Type the following commands (which switch to level 1, so we can remount the disk as read-only, check the disk before zeroing the free blocks, then finally remount the disk as read-write and shutdown).

    init 1
    mount -n -o remount,ro -t ext3 /dev/hda1 /
    fsck.ext3 -f /dev/hda1
    zerofree /dev/hda1
    mount -o remount,rw -t ext3 /dev/hda1 /
    shutdown -h now

    (2) Within Parallels in MacOS X, choose your virtual machine, click on the disk's configuration tab, and under advanced, choose "compact".

    You can now reboot your Linux VM, with its streamlined disk.
     

Share This Page