How to make a copy of a bootable Linux microSD

This article illustrates how to make a backup a bootable microSD

These procedures have been tested on a PC Linux with Ubuntu version 16.04.2

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

$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_

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_/.
$ sync
$ sudo umount /media/$USER/BOOT_ 
$ sudo umount /media/$USER/rootfs_

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

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 . 
...

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

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

$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 
$ sync
$ sudo umount /media/$USER/boot
$ sudo umount /media/$USER/rootfs

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

Sergio Tanzilli
System designer, webmaster and Acme Systems co-founder
Personal email: tanzilli@acmesystems.it
Webpages: https://www.acmesystems.it - https://www.tanzolab.it
Github repositories: https://github.com/tanzilli and https://github.com/acmesystems
Telegram group dedicated to the Acme Systems boards: https://t.me/acmesystemssrl

EUR 18.00


MICROSD8G-E - SanDisk industrial grade 8GB microSD

SanDisk 8GB Industrial grade microSD

| Product description |

Bruna Mandolino