2

This question already has an answer here:

If I dd my disk and compress the image with lzma or lzo the image is still big. The partition is 10GB used, 90GB available. But the image still around 20GB. I believe that is because I have copied many and deleted many files on that disk and the filesystem doesn't zero the unused blocks from those deletions.

How can I zero the unused blocks in order to minimize the disk image? So that dirty bytes don't add up on my image. I'm using ext4.

marked as duplicate by Gilles, cas, Raphael Ahrens, dr01, chaos Oct 6 '15 at 7:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please define effectively, is that different from just zeroing? Is there zeroing without having an effect? – Anthon Sep 29 '15 at 16:45
  • In this context one might rephrase the question to ask how to make an image backup of a filesystem that excluded unused blocks. – roaima Sep 29 '15 at 16:51
5

The tool you think you're looking for is zerofree, as described in this duplicate question Clear unused space with zeros (ext3,ext4), and already available in most distributions.

However, you seem to be asking how to take an image backup of a filesystem that excludes unused blocks. In this instance use fsarchiver, as described in this answer over on the AskUbuntu site.

  • zerofree seems to be what I'm looking for. I will test and get back to you. – Diogo Melo Sep 29 '15 at 17:02
  • partclone is another option. – derobert Sep 29 '15 at 20:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.