2

Hello i am running ubuntu mate on raspberry pi 3 and i would like to back up the img of the OS straight to an external usb. Do you have any suggestions ?

Is this going to work ?

sudo dd if=/dev/mmcblk0 of=/dev/sda1

Or should it be something like that :

sudo dd if=/dev/mmcblk0 of=/dev/sda1/backup.img

P.s when i run the second i get an error

3

Are you planning to run this directly from the raspberry PI itself? This could render inconsistencies in the filesystem copy. In order to do a full backup of the SD card you should insert the card in a computer and run a command similar to the one you've described.

About the two commands in your question:

Number 1 - Will work if sda1 is greater than mmcblk0. You would be wasting the remaining size of sda1 and will repeatedly be writing the same sectors of this destination device (not a good idea for flash memory).

Number 2 - You're are mixing device names (sda1) with filenames (backup.img). You are probably trying to do something like this:

sudo mkdir /tmp/backup_folder 
sudo mount /dev/sda1 /tmp/backup_folder 
sudo dd if=/dev/mmcblk0 of=/tmp/backup_folder/backup.img

What this commands do:

  • Create folder for mounting sda1
  • Mount sda1 in the folder created above
  • Create image of SD in the root of sda1 filesystem

One last remark. You are saving the swap partition if you have any. This is useless. You are also copying empty filesystem space. Take a look at partimage available in all major distros. It will use less space and time.

  • Thank you very much. Quite usefull answer :) – Ioan Kats Oct 4 at 12:29
  • "[#1] Will work if sda1 is greater than mmcblk0" -> Technically, but it would be a very unorthodox thing to do regardless of the size of sda1. You would not be able to tell where the image ends, either, without doing some forensics (and you'd have to remember where it was, because no tool would tell you "/dev/sda1 contains a device image"). – goldilocks Oct 4 at 13:57

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.