Dd – just copy partitions

ddpartitioningraspberry pi

I have a SanDisk Extreme SD card contaning my Homeserver runing on the RaspberryPI. I want to move this sytsem to another 4GB SD card using dd. But unfortunaltely when I make an image via dd it has the size of the entire SanDisk (16GB) althought just ca. 13.5 of them are partitioned. The Server SD consists of 2 partitions one small 50MB and a second 3 GB. I expected that dd makes an image of the size of the sum of the two partitions. Is there a way to make an image that contains just the really used disk space?

Best Answer

If the SD card is (for example) sdb, don't ask dd to read sdb, you could ask it to copy just the partitions by specifying (for example) sdb1 or sdb2. You'll have to partition the target device with equal sized partitions first and specify those as the targets.

Unix/GNU-Linux systems have a variety of tools for copying data

  • dd
  • cpio
  • dump
  • tar

It can be worthwhile reading a bit about each of them (e.g. the man pages but I suggest googling for an overview)


Also, dd has a count option so you can tell it to copy the first 4GB only.