Flashing or backing up your SD card » History » Version 2

Giulio Moro, 2015-09-25 12:34 AM

1 1 Giulio Moro
h1.  Flashing or backing up your SD card 
2 1 Giulio Moro
3 2 Giulio Moro
How to do it under MacOs and Linux. For both these tasks you will need the dd program. It comes with many Linux distributions and is available for MacOS.
4 2 Giulio Moro
5 2 Giulio Moro
h2. Backing up your SD card
6 2 Giulio Moro
7 2 Giulio Moro
Put your SD card in the SD card reader. We assume for the rest of this document that your SD card is /dev/mmcblk0
8 2 Giulio Moro
9 2 Giulio Moro
Start by unmounting the SD card in case it is currently mounted:
10 2 Giulio Moro
<pre>
11 2 Giulio Moro
$ sudo umount /dev/mmcblk0
12 2 Giulio Moro
</pre>
13 2 Giulio Moro
In case your partition is smaller than the size of the sd card, you do not need to backup the whole card, so if this is the case, run:
14 2 Giulio Moro
<pre>
15 2 Giulio Moro
$ sudo fdisk -u -l /dev/mmcblk0
16 2 Giulio Moro
</pre>
17 2 Giulio Moro
You might get something along the lines of
18 2 Giulio Moro
<pre>
19 2 Giulio Moro
            Device Boot      Start         End      Blocks   Id  System
20 2 Giulio Moro
    /dev/mmcblk0p1   *          63      144584       72261    c  W95 FAT32 (LBA)
21 2 Giulio Moro
    /dev/mmcblk0p2          144585     3743144     1799280   83  Linux
22 2 Giulio Moro
</pre>
23 2 Giulio Moro
You are interested in the higher value in the "End" column. Pass that value to dd as the count parameter:
24 2 Giulio Moro
<pre>
25 2 Giulio Moro
$ sudo dd conv=sparse count=3743144 if=/dev/mmcblk0 of=bbb_images/your_own_your_precious_backup_image.img
26 2 Giulio Moro
</pre>