How to make a copy of a bootable microSD

This article illustrates how to make a backup a bootable microSD using an Ubuntu 13.10 Linux PC

Direct copy between microSDs

Use this method if you want to make a copy directly without leave any backup on your PC

Format a new microSD following the instruction on this article:

Remove the target microSD and insert the original one. Three new folders will appear with the following path:

  • /media/$USER/boot
  • /media/$USER/rootfs
  • /media/$USER/data

$USER is an environment variable used by Linux for your user name.

Insert, in another reader, the just formatted target microSD. Other three new folder appear with path:

  • /media/$USER/boot
  • /media/$USER/rootfs_
  • /media/$USER/data_

Note the underscore (_) char at the end of each folder name.

Type these commands to copy all:

$ sudo cp -rp /media/$USER/boot/. /media/$USER/boot_/. 
$ sudo cp -rp /media/$USER/rootfs/. /media/$USER/rootfs_/.
$ sudo cp -rp /media/$USER/data/. /media/$USER/data_/.
$ sync
$ sudo umount /media/$USER/boot_ 
$ sudo umount /media/$USER/rootfs_
$ sudo umount /media/$USER/data_

Your copy is ready to be used, extract it and try.

Copy from microSD to a compressed set of files on HD

This method is useful if you want to have a snapshot of your microSD contents on your hard disk to use as master to create new copy.

Insert the master in your Linux PC. Three new folders will appear on your desktop:

  • /media/$USER/boot
  • /media/$USER/rootfs
  • /media/$USER/data

Open a terminal session and type:

$ cd /media/$USER/boot
$ sudo tar -cvjSf ../boot.tar.bz2 . 
...
$ cd /media/$USER/rootfs
$ sudo tar -cvjSf ../rootfs.tar.bz2 . 
...
$ cd /media/$USER/data
$ sudo tar -cvjSf ../data.tar.bz2 . 
...

The options mean:

  • -c create a new archive
  • -v verbosely list files processed
  • -j filter the archive through bzip2
  • -S handle sparse files efficiently
  • -f use archive file or device ARCHIVE

On the /media/$USER directory will appear new three tarbal files:

  • boot.tar.bz2
  • rootfs.tar.bz2
  • data.tar.bz2

These are the backup of your original microSD. They can be use to generate a new copy followinf the next instruction.

Create a new microSD from a compressed set of files

Format a new microSD following the instruction on this article:

Remove the just formatted target and insert it again to automount its contents.

Three new folders will appear with the following path:

  • /media/$USER/boot
  • /media/$USER/rootfs
  • /media/$USER/data

$USER is an environment variable used by Linux for your user name.

If your compressed backup files are on the same directory used to make them type:

$ sudo tar -xvjpSf /media/$USER/boot.tar.bz2 -C /media/$USER/boot 
$ sudo tar -xvjpSf /media/$USER/rootfs.tar.bz2 -C /media/$USER/rootfs 
$ sudo tar -xvjpSf /media/$USER/data.tar.bz2 -C /media/$USER/data 
$ sync
$ sudo umount /media/$USER/boot
$ sudo umount /media/$USER/rootfs
$ sudo umount /media/$USER/data

Your copy is ready to be used, extract it and try.

Author:
Sergio Tanzilli - tanzilli@acmesystems.it
http://www.tanzilli.com - https://github.com/tanzilli

MICROSD4G
EUR 8.00


Blank 4GB microSD HC card

Blank 4GB microSD memory card.

| Product description |

MICROSD8G
EUR 10.00


Blank 8GB microSD HC card

Blank 8GB microSD memory card.

| Product description |

MICROSD16G
EUR 14.00


Blank 16GB microSD HC card

Blank 16GB microSD memory card.

| Product description |

MICROSD32G
EUR 20.00


Blank 32GB microSD HC card

Blank 16GB microSD memory card.

| Product description |