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

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

1 1 Giulio Moro
h1.  Flashing or backing up your SD card 
2 1 Giulio Moro
3 6 Giulio Moro
For both these tasks you will need the @dd@ software. It comes with many Linux distributions and is available for MacOS and Windows, although I have not tried to use it on Windows myself.
4 2 Giulio Moro
5 1 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
6 2 Giulio Moro
7 3 Giulio Moro
Always start by unmounting the SD card in case it is currently mounted:
8 1 Giulio Moro
<pre>
9 1 Giulio Moro
$ sudo umount /dev/mmcblk0
10 1 Giulio Moro
</pre>
11 3 Giulio Moro
12 3 Giulio Moro
h2. Flashing an SD card
13 3 Giulio Moro
14 3 Giulio Moro
Whether you got an image from somewhere else or you want to flash your own backup image after you bricked your Beaglebone, do as follows:
15 3 Giulio Moro
make sure that the SD card is inserted and that none of its partitions are mounted as explained above.
16 3 Giulio Moro
Then:
17 3 Giulio Moro
<pre>
18 3 Giulio Moro
$ sudo dd if=~/bbb_images/your_own_your_precious_backup_image.img of=/dev/mmcblk0
19 3 Giulio Moro
</pre>
20 6 Giulio Moro
As it happens, @dd@ is a very simple program, so simple that it does not even display a progress bar.
21 6 Giulio Moro
If you are lucky enough to be on Linux, you can probably easily install pv which will display a progress bar for you:
22 3 Giulio Moro
23 3 Giulio Moro
pv ~/bbb_images/your_own_your_precious_backup_image.img | sudo dd of=/dev/mmcblk0
24 3 Giulio Moro
25 3 Giulio Moro
h2. Backing up your SD card
26 1 Giulio Moro
27 4 Giulio Moro
Make sure that the SD card is inserted and that none of its partitions are mounted as explained above.
28 4 Giulio Moro
29 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:
30 2 Giulio Moro
<pre>
31 2 Giulio Moro
$ sudo fdisk -u -l /dev/mmcblk0
32 2 Giulio Moro
</pre>
33 2 Giulio Moro
You might get something along the lines of
34 2 Giulio Moro
<pre>
35 2 Giulio Moro
            Device Boot      Start         End      Blocks   Id  System
36 2 Giulio Moro
    /dev/mmcblk0p1   *          63      144584       72261    c  W95 FAT32 (LBA)
37 1 Giulio Moro
    /dev/mmcblk0p2          144585     3743144     1799280   83  Linux
38 2 Giulio Moro
</pre>
39 2 Giulio Moro
You are interested in the higher value in the "End" column. Pass that value to dd as the count parameter:
40 2 Giulio Moro
<pre>
41 1 Giulio Moro
$ sudo dd conv=sparse count=3743144 if=/dev/mmcblk0 of=~/bbb_images/your_own_your_precious_backup_image.img
42 4 Giulio Moro
</pre>
43 4 Giulio Moro
44 5 Giulio Moro
If, instead, you want to backup the entire the SD card, simply use:
45 4 Giulio Moro
<pre>
46 4 Giulio Moro
$ sudo dd conv=sparse if=/dev/mmcblk0 of=~/bbb_images/your_own_your_precious_backup_image.img
47 2 Giulio Moro
</pre>