Linux – using dd with conv=sparse to punch zeros

dddisk-imagefat32linux

I am attempting to clone a disk partition to an image file using dd. I want to create the image without zeros to minimize the filesize, and on the other hand I do not want to pipe through gzip. The solution I found consists of writing zeros to a dummy file until the disk is full. The problem I am running into is this is a FAT32 filing system, so I am limited to making these dummy files 4.3GB. Tedious to say the least.

My question: If I have an already zero'd drive with a new partition table and freshly written data to the partition… would I be safe to skip the "filling the free space" step and just go right to running dd using conv=sparse? The entire drive had been zero'd out prior to partition creation, so I am confident that the free space should already be zeros.

Best Answer

Rather than trying to will unused space with zeroes, you could check out the partclone utility. This tool understands the FAT32 format (among others) and will automatically leave out unused space so your dump will be much smaller than if you do it with dd.