Backup and deploy
Contents
Introduction
We have been asked the questions by many individual users as well as some commercial users that "i have setup my own server on rock pro and running well, now i want to backup in case i lose data in the future" or "we have developed our own application and setup the environment now we want to install the same environment to 100 rock pro, how to do that". So we write this. This how-to tells you how to backup and restore the same firmware to your boards step by step. This how-to works for rock/rock pro/rock2 square. This how-to works under Linux. What you should know before read this:
- How to flash the image to nand/emmc
- How to go to loader mode, for rock/rock pro, for rock2 square
Backup
We use rkflashtool to backup each partition of the image, install it if you haven't.
sudo apt-get install libusb-1.0-0-dev git clone https://github.com/linux-rockchip/rkflashtool cd rkflashtool make
Put your device into Loader Mode and run the following command
sudo ./rkflashtool p > parameter.bak #fetch parameters
open parameter file and check out all the partitions. It's like this mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot)
sudo ./rkflashtool r boot > boot.img.bak sudo ./rkflashtool r linuxroot > linuxroot.ext4.bak # This will take a long time
Now you have parameter, boot, linuxroot partition backup.
Shrink rootfs
By default, linuxroot partition is very large(~8GB for rock pro), we can shrink it if the partition is not fully used. We can use gparted to shrink the rootfs.
sudo apt-get install gparted sudo gparted linuxroot.ext4.bak
And click Apply button to start shrink. Sometimes the gparted reports shrink failed but the actual size changed.
Restore
For one device
For one device, to restore is easy, just write back what we backup.
sudo ./rkflashtool P < parameter.bak sudo ./rkflashtool w boot < boot.img.bak sudo ./rkflashtool w linuxroot < linuxroot.ext4.bak
If you have 100 devices and want to restore, you can repeat above for 100 times but we have another way - pack the partitions to a rockchip format firmware and use RKbatchtool to flash each board automatically.
For a batch of devices
We use rockchip pack tools to generate the rockchip format firmware with the images we backup.
For rock/rock pro
git clone -b rk3188 https://github.com/radxa/rockchip-pack-tools.git
For rock2/rock2 square
git clone -b rk3288 https://github.com/radxa/rockchip-pack-tools.git
cd rockchip-pack-tools
replace the default parameter with the parameter we backup:
cp ../parameter.bak parameter
copy the backup partition here
mkdir Linux cp ../boot.img.bak boot-linux.img cp ../linuxroot.ext4.bak rootfs.img
generate the image
./mkupdate.sh
Now you get the rockchip format firmware that's the same as you backup. You can use RKbatchTool to flash multiple devices at the same time.
Help and Discussion
If you have any questions or stuck at some steps, post at this thread:
The community will help :)