At the moment pearpc supports sparse disk images by
using sparse file features from the host OS. The
problem with these sparse files is, that when you copy
them across disks or over the network, or if you
compress and uncompress them, they tend to explode to
their full size.
This patch adds support for a new type of diskimage:
PearPC sparse disk images. Only parts of the disk image
that contain non-zero blocks will be saved to disk and
use up disk space.
A PearPC sparse disk image will automatically grow when
more diskspace is needed. It's also possible to shrink
the sparse disk image if data is deleted from the disk
in the guest OS.
You can copy the PearPC sparse disk image across
filesystems and OS-es or burn the disk image on a DVD.
The sparse disk image will retain it's original size.
How to use PearPC sparse disk images: set the type of
diskimage in ppccfg.txt to 'sparsehd'. Here is a sample
pci_ide0_slave_installed = 1
pci_ide0_slave_image = "sparse.smg"
pci_ide0_slave_type = "sparsehd"
If 'sparse.smg' doesn't exist, a 6 GB PearPC sparse
disk image is created. After initial creation the file
will be 76 bytes in size. After formatting it will grow
to 8.5 MB. Once you start adding files, your disk image
will start to grow.
To shrink a PearPC sparse disk image after deleting
files you need to execute some Unix commands. These
unix commands will clear all unused diskspace. To do
this, start a terminal in the guest OS and execute the
dd if=/dev/zero of=zero.sparse.tmp ; rm zero.sparse.tmp
WARNING: If on your system, the file zero.sparse.tmp
exists and contains valuable data, choose a different
The 'dd' command will create a very large file called
zero.sparse.tmp and it will fill it with zeros only.
After all free space on the disk has been filled with
zeros, the file is removed.
You can track progress of the 'dd' command by looking
at the amount of disk space in use inside the guest OS.
It should slowly go all the way up to 100%. At the same
time, the PearPC sparse disk image file on your host OS
should slowly shrink. As soon as the 'dd' command
completes, the disk usage in the guest OIS drops again
to what it was before you started the 'dd' command.
This disk cleaning can take up to 40 minutes for a 6 GB
Over time the disk image will slowly grow: Your guest
OS will accumulate clutter. It might optimize the disk
every now and then, your browser cache will grow and
shrink. When installing a new piece of software some
intermediate files might be needed. All this data will
be stored in the sparse disk image and can only be
cleared by cleaning the disk with the 'dd' command as
This implementation has been tested under Windows and
Linux on Intel hardware. The implementation should also
run on big endian processors, but the big endian
implementation has only been tested on little endian
BeOS support hasn't been tested. It also lacks the
possibility to shrink disks. This can be fixed by
adding a one-liner in src/system/osapi/beos/sysfile.cc
. The function sys_truncate_sys_file needs to be
implemented. Two possible solutions are mentioned there.
And please be aware of the fact that you can lose
valuable data if there are still some bugs left in this
code. Please use it for testing purposes only until
enough reports have come in that it is bug free.
Log in to post a comment.