Score:2

create clone with dd to another drive

in flag

So I want to backup what I have done to Raspian using my Ubuntu laptop and followed the advice at the below link. so using this command... sudo dd if=/dev/mmcblk0 of=~/sd-card-copy.img bs=1M status=progress this is all very good, however, my laptop only has 24Gb spare and the memory card is 128Gb! this command seems to want to write the entire memory card size even though it is only 10Gb of data.

I have a server address I can share to that has the space, but how do I direct the 'dd' command to another area? At first I thought I could change to that directory and run the command but that starts putting it into my 'home' folder. thanks in advance for help.

SD card cloning using the dd command

Score:4
ro flag

First, I think its important to understand the command you're using. dd by its very nature is a bit-by-bit copy of the if (input-file) which results in a perfect copy of the file when you give it an of (output-file). This includes any zeros. You also have to remember that the file table does not actually represent what is on the device, just what you can normally see. That's why when you try and recover files using recovery software you can often times recover files that are not yet overwritten. Files are deleted from the table allowing the space they consumed to be listed as "free" and other files to write over top of those "deleted" files. They aren't typical scrubbed in most filesystems in the interest of saving time on a delete.

Your of= option takes a path to a file, so if you are trying to get the output in the directory you're currently working in pwd then of=sdcard-copy.img should suffice.

That being said, you have an alternative option for saving output:

You could compress the output with gzip to save it: dd bs=1M if=/dev/mmcblk0 | gzip -c > sdcard-copy.img.gz

and decompress it on the restore phase: gunzip -c sdcard-copy.img.gz | dd of=/dev/sdb bs=1M or whatever your intended target device is (I would suspect sda)

The downside to this is that it will take some time to compress/decompress vs just plain copying. For your case that may actually be pretty fast if the source is mostly zeros (which it sounds like it is).

styleruk avatar
in flag
OK, that works on making the img and compressing it. Thank you, at least I have a backup of the image now and it's much smaller as expected. Having trouble mounting a different card for now, will try the de-compression when I've figured that out. Thank you.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.