I'm trying to make a backup of a block device (Raspberry Pi sd card) using dd. Command used:

sudo dd if=/dev/sdb of=rpi-backup-image bs=4MB

where /dev/sdb is the unmounted RPi sd card. The amount of data being backed up is multiple gigabytes large and it byte copies the content of the whole disk. However, the actual "used space" (sensible data on partitions) is only two gigabytes. Is there a way to dd only the sensible data? Perhaps some other tool?

Note: I'm not looking for ways to compress the image after it has been dd-ed.

  • if you zero the disk beforehand it won't do that. you can do cp --sparse-always /dev/sdb ./img but that might have the same issue - dd shouldnt try so hard for null runs, and so that's probably actual data. filesystem != data. you have to clear the parts that are not being used for them to look not used to anything but the filesystem. so ... </dev/zero tee >zero zero1 zero2 and let it run. afterward, it should be a lot faster, as long as your sd firmware isn;t too smart. – mikeserv Jan 13 '16 at 10:45
  • serverfault.com/q/439128/150015 – Torxed Jan 13 '16 at 10:49
  • 1
    What's the filesystem on the SD card? ext4? You need a filesystem-aware tool if you want to only read the areas that are effectively used by the filesystem. – Gilles 'SO- stop being evil' Jan 13 '16 at 23:32
  • Use a different method. Like Gilles says, you need a filesystem-aware tool. Is this an ongoing/incremental backup, or a one-time backup? For a one-time backup, fsarchiver is good. – Faheem Mitha Jan 14 '16 at 4:42

If sdb is partitioned, you could backup just the partition with the data of interest.

For example:

sudo dd if=/dev/sdb1 of=rpi-backup-image bs=4MB

  • 2
    This will be equally as slow if the petition spans the entire disk? – Torxed Jan 13 '16 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.