I have a 64 GB Linux disk image with ~50 GB of unused space across the partitions. The file is sparse, so it only takes ~14 GB on disk.
But if I dd
the image, it writes the full 64 GB, which takes quite a while.
Is there any way I can do the equivalent of dd if=os.img of=/dev/sdb
with this image, without having to write 50 GB of zeros?
Is there any tool that is smart enough to do this i.e. an imaging tool that has an awareness of the EXT4 filesystem?
os.img
can be important. For example, a filesystem that uses a bitmap to keep track of free blocks may have a full bock of zero bytes in this bitmap. This block of zero bytes must go onto the disk. If the disk has other data from previous use in this location and the block is skipped when writing as it is sparse inos.img
, the filesystem will be inconsistent and may use some blocks twice, for different files.