0

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.

  • This doesn't exactly answer your question, but maybe you should check out the [partclone](http://partclone.org) utility, which seems to "understand" FAT32. It should therefore automatically "leave out" unused space and produce a smaller image than dd. – Oliver Apr 28 '17 at 14:28
  • I'm not married to dd. It just seems to be quick and effective if used correctly. I will try partclone. I assume if its not a part of my already installed packages, I will obtain and test. Thank you for the timely response, friend! – Thomas A Anderson Apr 28 '17 at 14:31
  • ># partclone.fat32 -cs /dev/sdb1 -o /media/user0/5acf82c8-507a-479c-adac-a947fc7065d8/sdb1.fat32 done! File system: FAT32 Device size: 125.0 GB = 244197376 Blocks Space in use: 39.9 GB = 77865216 Blocks Free Space: 85.2 GB = 166332160 Blocks I see how it calculates the free space... and I assume it does not image that portion of the partition? – Thomas A Anderson Apr 28 '17 at 14:55
  • Im noticing the output shows that the total blocks matches the size of the entire partition. "current block: 40730548, total block: 244197376, Complete: 16.68%". I'm hoping it will reach the in use block count and complete. I fear that I missed a switch or argument to exclude free space. – Thomas A Anderson Apr 28 '17 at 15:07
  • I see... it is processing the entire partition and omitting the free space when it writes the image. The final file size was correct. Thank you Oliver for this wonderful solution! – Thomas A Anderson Apr 28 '17 at 15:21
  • Glad to know it worked! I have added my comment as an answer now. – Oliver Apr 28 '17 at 15:34
  • I'm obviously new here... is there a way that I can give you a thumbs up, like, upvote, etc? – Thomas A Anderson Apr 28 '17 at 15:43

1 Answers1

1

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.

Oliver
  • 5,883
  • 23
  • 32