Introduction: 1.6.1.Backup and Restore System

Sometimes you want to backup your system for pcDuino8 Uno. The simplest way is using dd
on Linux or Win32DiskImager on Windows to read back the whole TF card and save it as system image file. If I use 8G TF card, the backup image file will be 8G, but in fact, the system just take 2G disk space.So how can I backup a smaller system image? The following steps will tell you.

Pre-requisites

TF card readerPC running Linux OS Steps about backup

1. Set a first boot flag

In official Ubuntu image for pcDuino8 Uno, there is a shell script at /etc/init/, called pcduino.conf. This is the init script for pcDuino board, and one job of this script is used to expand the rootfs. Each time system boots, this script will check there is pcduino_init_flag file at /etc or not. If yes, resize the rootfs. If we want to create a auto-resized system image, we need to create pcduino_init_flag.

Login Ubuntu on pcDuino8 uno and run commands as follows to create the pcduino_init_flag file:

cd /ect/
vim pcduino_init_flag

2. Install pgarted tool
On another PC running Linux(Take Ubuntu as example), not on your pcDuino8 Uno, install gparted tool which can resize your disk partition.

sudo apt-get -y install gparted

3. Resize your partition using gparted
Shut down pcDuino8 Uno, remove TF card and insert it into Linux PC, then open gparted.

sudo gparted /dev/sdb

Note: Suppose your TF card is recognized as /dev/sdb.
Right click the partitions that have been mounted, then umount them. umount

Right click the partition which need to shrink and select resize.

Set Free space preceding(MiB) is 0, this guarantee the continuity of these three partitions.

Set Free space following(MiB), make sure the partition still have about 300MB space. resize2 Apply all operations.

4. Generate image file

$ sudo dd if=/dev/sda of=/system.img bs=1M count=2500

Take my case, I resize the partitions from 8GB to 2.4GB, so I set count as 2500 to make sure dd should not damage system file.
Furthermore, you can use tar or 7z to compress the image file. As to me, I use 7z tool to compress it and get an compressed file whose size is only about 650MB.

5. Restore system from image file

On windows, you can use win32disk tool to write the image file into TF card.

As to Linux, also use dd like:

sudo dd if=/system

Note: /dev/sda is your TF card.
6. Run

Insert the TF card into pcDuino8 Uno and after the second boot, all things are back to normal.

Maybe you can directly use dd to backup the system into a smaller image file, but I have never try it.

Comments

About This Instructable

39views

0favorites

License:

Bio: Let's play together! All about pcDuino,Arduino,Raspberry pi and technology. My facebook :Sherry Wu https://m.facebook.com/sasha.wu.775
More by shansa wu:How to Use App to Control Your LED StripPano 360 Virtual Reality Photo Shot With PcDuino8 UnoTutorial of Using E-paper Shield on Arduino
Add instructable to: