Wednesday, January 6, 2016

[Tutorial] Install zerofree on CentOS 6, 7, Redhat, Fedora, ...

You might need zerofree when you want to compact your VM's hard disk. There's no RPM package of this application for Centos 6 or 7 (rhel 6 & rhel 7) so the only way is to compile it from the source. It goes like this:

yum install e2fsprogs-devel -y
wget http://frippery.org/uml/zerofree-1.0.3.tgz
tar -zxf zerofree-1.0.3.tgz
cd zerofree-1.0.3

make


after successfully building the application, copy it to /usr/bin

cp zerofree /usr/bin

Now you can remount the destination partition as read-only and zerofree it!

You can also use dd instead of zerofree:

dd if=/dev/zero of=test.file
 
...wait for the virtual disk to fill, then
 
rm test.file

and shut the VM down. Then on your VirtualBox host do:
 
VBoxManage modifyhd --compact yourImage.vdi

3 comments:

How to disable Debian 12 sleep on production servers

 Debian 12 has power saver enabled by default which causes your server to go to sleep if there is no mouse / keyboard interaction. To resolv...