Export the root file system on the RK3588 development board and make an img image

Export the root file system on the RK3588 development board and make an img image


The specific process is divided into three steps:

  • Copy the entire root file system file of the development board RK3588 to the PC system (Ubuntu) through ssh;
  • Load all the copied files into the virtual disc and make them into img files;
  • Burn the img file back to the RK3588 development board for testing.

Pre-preparation

The file system on the development board RK3588 needs to be installed: ssh, rsync;
installed on the local PC or virtual machine (Linux): ssh, rsync.

The Linux system obtains the file system of the RK3588 development board

Make sure rsync is installed on the RK3588 development board system

sudo apt-get install rsync

Create a directory on this machine to store the file system of the RK3588 development board

mkdir rootfs

Synchronize the file system of the development board to ensure that the device can ping the development board, execute:

#RK3588 IP 为 192.168.1.11
sudo rsync -avx [email protected]:/ rootfs

After execution, the file system of the development board can be synchronized to the host

Make a mirror image, use the dd tool to create a mirror image file, and execute the command on the host (you can create an empty img file with a size of 3000M, and the size can be modified for the count value)

dd if=/dev/zero of=rk3588.img  bs=1M count=3000

/dev/zero: The name of the virtual disk.
rk3588.img: the image file to be built.
bs=1M : Indicates that each block reads and writes 1M data.
count=3000: the number of copied blocks.

Format the image file and add the linuxroot volume label

sudo mkfs.ext4 -F -L linuxroot rk3588.img

Mount the mirror and copy the modified file system into it

#创建镜像文件挂载目录
mkdir ubuntu-mount
#挂载空的 img 文件
sudo mount rk3588.img ubuntu-mount
#将文件系统拷贝到 img 挂载的路径目录下
sudo cp -rfp rootfs/* ubuntu-mount

uninstall image

sudo umount ubuntu-mount

In this way, rk3588.img already contains the content of the root directory just made, but the size of the rk3588.img file is the defined partition size, not the actual size of the file system, so it needs to be processed before it can be released.

Check and repair the file system of the rk3588.img image

sudo e2fsck -p -f rk3588.img

Reduce the size of the rk3588.img image file

sudo resize2fs -M rk3588.img

Burn test

The file system of the development board has been repackaged into rk3588.img. This file and the corresponding kernel file can be used to generate a system image. After burning the image, the user program can be run directly, thus saving the need for reinstalling the package and other configurations. Work.

After the image file is generated, it can be re-burned to the development board for testing

burn img to device rootfs partition

Connect the development board to the Windows computer, and open the RKDevTool burning tool, so that the development board enters the Loading mode;
select the rootfs partition, and select the root file system rk3588.img made earlier to burn;
after the burning progress is 100%, the development board will Automatically restart and enter the new system.

Guess you like

Origin blog.csdn.net/qq_37596943/article/details/127340405