3

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.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
Diogo Melo
  • 153
  • 2
  • 7
  • 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. – Chris Davies Sep 29 '15 at 16:51

1 Answers1

7

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.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287