Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

The easiest way to zero out unused space is to mount the image, fill up the space with zeroes, and remove the zero-filled file.

mount -o loop /path/to/image /mnt
cat /dev/zero >/mnt/zero
rm /mnt/zero
umount /mnt

Depending on what the filesystem is, there may be tools that can work directly on the image. See this question for ext2/ext3/ext4this question for ext2/ext3/ext4 (answer: zerofree).

The easiest way to zero out unused space is to mount the image, fill up the space with zeroes, and remove the zero-filled file.

mount -o loop /path/to/image /mnt
cat /dev/zero >/mnt/zero
rm /mnt/zero
umount /mnt

Depending on what the filesystem is, there may be tools that can work directly on the image. See this question for ext2/ext3/ext4 (answer: zerofree).

The easiest way to zero out unused space is to mount the image, fill up the space with zeroes, and remove the zero-filled file.

mount -o loop /path/to/image /mnt
cat /dev/zero >/mnt/zero
rm /mnt/zero
umount /mnt

Depending on what the filesystem is, there may be tools that can work directly on the image. See this question for ext2/ext3/ext4 (answer: zerofree).

Source Link
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k

The easiest way to zero out unused space is to mount the image, fill up the space with zeroes, and remove the zero-filled file.

mount -o loop /path/to/image /mnt
cat /dev/zero >/mnt/zero
rm /mnt/zero
umount /mnt

Depending on what the filesystem is, there may be tools that can work directly on the image. See this question for ext2/ext3/ext4 (answer: zerofree).