Recently I was creating for somebody empty virtual image based on my actual image. I want to make sure the image will get compressed as much as possible. But I delete there about 1,5 GB of my data.
To make sure the VM will be compressed I needed to fill all empty space with 0.
I found this tool to do that: http://frippery.org/uml/index.html , but it was little bit tricky.
Here is step by step how to proceed:
1) Download the zerofree from http://frippery.org/uml/zerofree-1.0.3.tgz
2) Unzip it.
3) You might need to install package with headers for ext drive called e2fsprogs-devel. At centos call
yum install e2fsprogs-devel
4) go to folder with zerofree and call
make
5) now you need to reboot the system into readonly mode – restart the VM and when you get the loader screen press space or Esc.
6) run the linux in readOnly mode by adding parameters
ro init=/bin/bash
(at Grub it’s a command “a”)
7) once you are at the console go to folder where is zerofree
8) call mount command to get the name of the disk .. in my case it’s /dev/mapper/VolGroup-lv_root
9) then simply call
zerofree /dev/mapper/VolGroup-lv_root
That’s all
Leave a Reply