8

Often times I see this command for use when creating a Vagrant box

sudo dd if=/dev/zero of=/EMPTY bs=1M

To me it seams that it is copying a lot of NULL characters into a file named EMPTY at the FS root 1MB at a time. My question is how does doing this optimize the space usage on the disk once the file is removed.

Heath N
  • 183
  • 1
  • 3

1 Answers1

13

It effectively writes zeroes to all empty space on the volume; this allows for better compression of the physical file containing the virtual disk.

Massimo
  • 70,200
  • 57
  • 200
  • 323
  • 1
    I've used this "technique" a lot. I'd install Windows for my family on a partition, filled the filesystem with zeroes like this, and then simply gzipped the entire partition. The restore was extremely simple, and the backed up file was very compact. :) – Vladimir Mar 20 '15 at 15:51