Linux Root Filesystem and System Backup¶
| SDK | Supported Motherboards | Buildroot | Debian | Ubuntu |
|---|---|---|---|---|
| rk356x_linux | K1 / K1B / K1MINI / K3 / K3B / K8 / K8D / K11C | - | Debian11 | Ubuntu20.04 |
| rk-linux6.1 | K1MINI / K3B / K8D / K11C | - | Debian12 | Ubuntu24.04 |
| rk3576-linux | K7 / K7C / K7S-K7F | - | Debian12 | Ubuntu24.04 |
| a733-linux | K10B | - | Debian11 | - |
| a133-linux | K5C | - | - | - |
| t113-linux | K4B | buildroot2019 | - | Ubuntu20.04 |
| t527-linux | K9 | - | Debian11 | - |
Root Filesystem Customization¶
Note
For root filesystem customization in img or tar.gz format, it is recommended to export the filesystem from the board and replace it.
| SDK | Rootfs | Overlay |
|---|---|---|
| rk356x_linux | debian/linaro-rootfs.img ubuntu/ubuntu-rootfs.img |
- |
| rk-linux6.1 | debian/mk-rootfs-bookworm.sh ubuntu/mk-rootfs-noble.sh |
debian/overlay ubuntu/overlay |
| rk3576-linux | debian/mk-rootfs-bookworm.sh ubuntu/mk-rootfs-ubuntu2404.sh |
debian/overlay ubuntu/overlay |
| t113-linux | device/config/rootfs_tar/ubuntu-armhf.tar.gz | device/config/rootfs_tar/install_libs/evb1_auto/ |
| a133-linux | device/config/rootfs_tar/rootfs_ubuntu_kickpi_k5_1604lts.tar.gz | overlay |
| t527-linux | debian/compressed_files/linaro-bullseye-xfce-arm64.tar.gz | debian/overlay |
| a733-linux | debian/compressed_files/linaro-bullseye-xfce-arm64.tar.gz | debian/overlay |
Filesystem Backup¶
Exporting the Filesystem¶
Use the ff_export_rootfs tool to export the root filesystem as an image.
Note
FAT32 has a single-file size limit of 4 GB. It is recommended to format the USB drive as ext4 or exFAT.
sudo chmod +x /usr/bin/ff_export_rootfs
sudo ff_export_rootfs /mnt/usb -t ext4
# Export successful
Export rootfs to /mnt/usb/rootfs.img Success
# Verify the format
file /mnt/usb/rootfs.img
# Linux rev 1.0 ext4 filesystem data ...
Replacing the Filesystem¶
On Rockchip platforms, rootfs.img can be used for standalone flashing to replace the board's filesystem, or it can be repackaged into a full firmware image.
Tip
After replacing the rootfs, there may be a UUID mismatch. Use blkid to check the correct UUID and modify /etc/fstab accordingly.
If the root partition has insufficient space after flashing, use the resize2fs command to expand the root filesystem.
Full System Backup¶
Exporting the System to an SD Card¶
Using dd
Note
Hardware requirement: SD card (write speed ≥ Class 10)
# List block devices
$ lsblk
mmcblk0 179:0 0 7.2G 0 disk # eMMC (system disk)
mmcblk1 179:48 0 58.6G 0 disk # SD card
# Unmount partitions and format the SD card
sudo umount /dev/mmcblk1p1
sudo mkfs.ext4 /dev/mmcblk1
# Full disk copy via dd (takes approximately 10–25 minutes)
sudo dd if=/dev/mmcblk0 of=/dev/mmcblk1 bs=4M status=progress
Using nand-sata-install
Exporting the System to a USB Drive¶
# Mount the USB drive
mkdir -p /mnt/usb
mount /dev/sda1 /mnt/usb
# Export the entire eMMC as an image
sudo dd if=/dev/mmcblk0 of=/mnt/usb/output.img bs=4M status=progress
sync
The generated output.img can be used for direct flashing.
Firmware Unpacking and Repackaging¶
Note
Rockchip firmware supports unpacking and repackaging.
- Tool Acquisition
1. Click to download the tools, or find them in the SDK.
// Linux-SDK source path:
rk356x-linux\tools\linux\Linux_Pack_Firmware
// Android-SDK source path:
rk-android13.0\RKTools\linux\Linux_Pack_Firmware
- Unpacking
1. Place the Linux_Pack_Firmware directory in your virtual machine working directory.
2. Place the firmware to be unpacked in the rockdev directory and rename it to update.img.
cd Linux_Pack_Firmware/rockdev
mv update-rk3568-kickpi-k1-linux-debian--20250403-150845.img update.img
3. Run the script to unpack the firmware:
4. The unpacked files will be located at:
- Repackaging
Tip
After modifying the unpacked images, you can repackage the firmware.
1. Copy the files to the corresponding paths under rockdev and delete the previously used update.img:
2. Modify the package-file to update the file paths:
# NAME PATH
package-file package-file
parameter Image/parameter.txt
bootloader Image/MiniLoaderAll.bin
uboot Image/uboot.img
misc Image/misc.img
boot Image/boot.img
recovery Image/recovery.img
backup RESERVED
rootfs Image/rootfs.img
3. Run the appropriate packaging script:
4. The repackaged firmware will be located in the rockdev directory:
Partition Configuration¶
Allwinner Partitions¶
| Motherboard | SDK | Partition Table |
|---|---|---|
| K4B | t113-linux | device/config/chips/t113/configs/evb1_auto/buildroot/sys_partition.fex device/config/chips/t113/configs/evb1_auto/ubuntu/sys_partition.fex |
| K5C | a133-linux | device/config/chips/a133/configs/c3/android/sys_partition.fex |
| K9 | t527-linux | device/config/chips/t527/configs/demo_linux_aiot/debian/sys_partition.fex |
| K10B | a733-linux | device/config/chips/a733/configs/demo_aiot/debian/sys_partition.fex |
A133 Partition Example:
# fdisk -l
/dev/mmcblk0p1 32M
/dev/mmcblk0p2 16M
/dev/mmcblk0p3 64M
/dev/mmcblk0p4 6G (rootfs)
/dev/mmcblk0p5 16M
/dev/mmcblk0p6 1.1G (UDISK)
Modifying the rootfs partition size:
--- a/device/config/chips/a133/configs/default/sys_partition.fex
+++ b/device/config/chips/a133/configs/default/sys_partition.fex
@@ -53,7 +53,7 @@ size = 16384
[partition]
name = rootfs
- size = 14931722
+ size = 12582912
downloadfile = "rootfs.fex"
user_type = 0x8000
Rockchip Partitions¶
There are two ways to modify partitions:
- Full firmware modification
Refer to Firmware Unpacking and Repackaging, modify the parameter.txt file, and then repackage.
- Modification within the SDK
After modifying the file in the corresponding path, recompile.
| Motherboard | SDK | SoC | Partition Table Path (relative to SDK root) |
|---|---|---|---|
| K1/K1B/K11C/K1MINI | rk356x-linux | RK3566/RK3568 | device/rockchip/.chips/rk3566_rk3568/parameter-buildroot-fit.txt |
| K3/K3B | rk356x-linux | RK3562 | device/rockchip/.chips/rk3566_rk3568/parameter-buildroot-fit.txt |
| K8/K8D | rk356x-linux | RK3588 | device/rockchip/.chips/rk3588/parameter.txt |
| K1MINI/K11C | rk-linux6.1 | RK3566/RK3568 | device/rockchip/.chips/rk3566_rk3568/parameter-buildroot-fit.txt |
| K3B | rk-linux6.1 | RK3562 | device/rockchip/.chips/rk3562/parameter-buildroot-fit.txt |
| K8D | rk-linux6.1 | RK3588S2 | device/rockchip/.chips/rk3588/parameter.txt |
| K7/K7C/K7S | rk3576-linux | RK3576 | device/rockchip/.chips/rk3576/parameter.txt |
Modification Content:
Repartitioning mainly involves modifying the parameter.txt file.
Example: Allocate all remaining space to the root partition.
mtdparts=:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),-@0x00078000(rootfs:grow)
Note
Partition rule:
Partition size: 0x01c00000 × 512 bytes / 1024 / 1024 / 1014 ≈ 14 GB
Partition start address: previous partition's start address + previous partition size
The last partition is specified as -@0x0xxxxx(xxx:grow). The - indicates that all remaining space is allocated automatically.
For Linux systems, an additional step is required: comment out the automatic mount of oem and userdata.
Ubuntu Filesystem Modification¶
This operation is only applicable to boards equipped with the T113 platform. Before compiling, if you need to modify the Ubuntu root filesystem (installing packages, replacing configurations, etc.), two methods are provided: chroot mount modification (suitable for large-scale changes) and overlay override (suitable for small file replacements).
Method 1: chroot Mount Modification¶
By emulating the ARM environment on the host machine, you can directly modify the Ubuntu image, as if you were operating as the root user on the board.
1. Set up the build environment (only needs to be installed once).
2. Back up the original image.
3. Extract the image.
4. Mount and enter the chroot environment.
# Mount
./ch-mount.sh -m rootfs_k4b
# Configure DNS and QEMU emulator
sudo cp -b /etc/resolv.conf rootfs_k4b/etc/resolv.conf
sudo cp -b /usr/bin/qemu-arm-static rootfs_k4b/usr/bin/
# Enter chroot
sudo chroot rootfs_k4b
5. Make modifications inside the chroot.
export LC_ALL=C.UTF-8
# Configure DNS
echo "nameserver 8.8.8.8" >> etc/resolv.conf
echo "nameserver 114.114.114.114" >> etc/resolv.conf
# Verify network connectivity
ping www.baidu.com
# Update package sources
apt-get update
apt-get upgrade
# Install required packages or modify files
apt install <package_name>
After completion, exit the chroot:
6. Unmount: You must unmount before proceeding to the next packaging step; otherwise, the image will be corrupted.
7. Repackage the image.
rm -v ubuntu-armhf.tar.gz
cd rootfs_k4b/
sudo tar -zcf ../ubuntu-armhf.tar.gz .
cd ..
ls ubuntu-armhf.tar.gz # Verify the new image has been generated
8. Recompile; the new rootfs will be packaged into the final image during compilation.
Method 2: overlay Override¶
Suitable for quickly replacing a small number of files without mounting or repackaging. Place the files in the specified directory, and they will be automatically copied to the corresponding paths in the rootfs during compilation.
Target directory:
Example: Place the script test.sh into /etc/test.sh in the root filesystem:
# The source path is a direct mapping to the target path
cp test.sh device/config/rootfs_tar/install_libs/evb1_auto/etc/test.sh
The directory structure mirrors the target rootfs. For example, evb1_auto/usr/bin/myapp will be compiled to /usr/bin/myapp.
After placing the files, compile directly: