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)

Timmy
  • 111
  • 5

3 Answers3

1

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

Andy Anderson
  • 649
  • 1
  • 4
  • 11
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

zarvox
  • 371
  • 1
  • 3
  • 6
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.

Milliways
  • 62,573
  • 32
  • 113
  • 225