1

Environment:

  • My laptop OS: Linux Mint 18.2 Cinnamon 64-bit - Kernel: 4.10.0
  • My Raspberry OS: Raspbian Stretch with desktop (Version: August 2017) - Kernel: 4.9
  • Raspberry is installed on a 16GB SD card
  • When the Raspberry SD is inserted into my laptop through a working card reader I can see these two partition: /dev/mmcblk0p1 and /dev/mmcblk0p2

Short question:

  • How to make a full backup of the raspberry SD in order to move the OS on another SD.

Full question:

In order to backup the SD I followed this guide: https://www.raspberrypi.org/documentation/linux/filesystem/backup.md

  1. Backup of the boot partition: sudo dd bs=4M if=/dev/mmcblk0p1 of=raspbian_boot.img
  2. Backup of the main partition: sudo dd bs=4M if=/dev/mmcblk0p2 of=raspbian.img

Well now I've these 2 img file: raspbian.img (~16GB) and raspbian_boot.img (~44MB), how can I restore these ones?

I know that I've to use these:

  1. sudo dd bs=4M if=raspbian_boot.img of=/dev/mmcblk0p1
  2. sudo dd bs=4M if=raspbian.img of=/dev/mmcblk0p2

But the real problem is: how should I partition the new SD? Which file system for each img? The first one has 3 different partitions (the first: /dev/mmcblk0p0 is not allocated at all)

3 Answers 3

1

Piclone (SD Card Copier) is included. Use that to copy direct to another card.

0

I see two posibilities, use dd to clone a complete RP sd card (not only the partitions) and then you can use dd to restore the partitions from the images files. This is easy but takes longer. Or you can do the math for the formatting params based on sector- or blocksize on the old sd card. Use fdisk to see the partition layout and use a guide like this: http://www.tldp.org/HOWTO/Partition/fdisk_partitioning.html

3
  • Honestly what I'm trying to do is make a full backup that I can easily restore using a dd command, but what I've done is working. I still can create a new backup, the real question is how.
    – Timmy
    Commented Aug 30, 2017 at 11:28
  • 1
    This is what I do: I shutdown my PI. Put the sd card in my linux server and make a image with dd from the whole sdcard wich I can restore with one single dd cmd. check this answer (how-to-clone-raspberry-pi-sd-card)
    – zarvox
    Commented Aug 30, 2017 at 11:33
  • The difference is that you make two images (boot and raspbian.img) and I make only one from the whole card and I do it on an other machine.
    – zarvox
    Commented Aug 30, 2017 at 11:42
0

You are making life difficult for yourself; backup the whole SD Card. It is possible to also backup the "boot" sector sudo dd if=/dev/mmcblk0 of=boot-sector.img bs=512 count=1, or generate a new one (using fdisk).

Unfortunately your backup will not work! You need to backup to an external device, or perform on another system (in which case mmcblk0 is wrong).

Also your restore will not work. You cannot restore over the mounted partitions, and need an external device.

6
  • Right now I still have a working system so I can repeat the backup. So you suggest me to do this in order to make a full backup of the sd : sudo dd if=/dev/mmcblk0 of=boot-sector.img bs=512 count=1, then to restore the whole system using this other command: sudo dd if=boot-sector.img of=/dev/mmcblk0 bs=512 count=1. Is it correct?
    – Timmy
    Commented Aug 30, 2017 at 11:24
  • 1
    The code I suggested will only backup the boot sector. I recommend you follow the tutorial you listed i.e. sudo dd bs=4M if=/dev/sdb of=raspbian.img on a Linux system. You have not actually provided enough details of your system to give a definitive answer. sudo dd bs=4M if=/dev/mmcblk0 of=/mnt/storage/raspbian.img can be used to backup to an external drive on the Pi.
    – Milliways
    Commented Aug 30, 2017 at 12:02
  • Ok, I can extract the SD and connect it to another Linux device through a card reader (/dev/mmcblk0), how can I make a full backup of the SD in order to eventually restore it later or in another SD? I can give you more information if needed, just ask me what you need to know.
    – Timmy
    Commented Aug 30, 2017 at 15:50
  • @Timmy You had not indicated what system or how you are using the SD Card (all this should be edited into your question). You seem to be fixated on /dev/mmcblk0 which ONLY applies on the Pi. The link you included shows how to backup and restore on Linux. If you have problems understanding this you need to ask, NOT just list commands, which are wrong.
    – Milliways
    Commented Aug 31, 2017 at 1:44
  • Added further information to be more clear and yes, I'm trying to make a full backup of the raspberry SD but I don't understand how to do it because I've more than one partition, here is my bigger problem. I hope these information are enough to anser to my question.
    – Timmy
    Commented Sep 1, 2017 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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