Jul 27, 2024, 12:26 PM

The partitioning situation of the Coolpi image file is as follow

  • The first partition has a size of 512M and a partition format of fat32, used to store boot- files. The default boot mode is extLinux.
  • The second partition is the file system, with different sizes depending on the distribution. The partition format is ext4. The label of the partition is writable, which needs to be consistent with the configuration information under extLinux.
    Screenshot from 2024-07-27 12-04-32.png
  • The file of the boot partition is shown in the following figure, which you can access through/ The build kernel. sh command compiles the coolpi kernel, and then the files in the out directory need to be copied to the boot partition.
    96cdbbc0-a6ba-4faa-8a41-de671af7e750-image.png
  • The content is as follows extlinux.conf,Pay special attention to the loading method of the file system, which is searched through label (writable). Of course, it can also be modified to UUID or other types.
default Linux coolpi

label Linux coolpi
	kernel /Image
	initrd /initrd.img
	fdt    /rk3588-cpcm5-notebook-v20.dtb
	append root=LABEL=writable rw rootfstype=ext4 console=ttyS0,115200n81 quiet splash plymouth.ignore-serial-consoles vt.global_cursor_default=1 irqchip.gicv3_pseudo_nmi=0 net.ifnames=0

Start creating a mirror image

  • Create an 8GB img file using the following command. Then partition and format.
LOOP_NUMBER=$(losetup -f)
dd if=/dev/zero of=./coolpi.img bs=1M count=8192    
printf 'n\np\n1\n32768\n1081343\nn\np\n2\n1081344\n16777215\nw\n' | fdisk ./coolpi.img   
partx -a -v ./coolpi.img      
mkfs.vfat $LOOP_NUMBER"p1"      
echo 'yes\n' | mkfs.ext4 $LOOP_NUMBER"p2"   
e2label  $LOOP_NUMBER"p2" writable
  • Copy files to boot partition,kernel-dir is the file directory corresponding to the Coolpi kernel.
mkdir ./mnt
mount $LOOP_NUMBER"p1" ./mnt
cp  kernel-dir/out/* ./mnt -r
umount  ./mnt
  • Create a file system, Add rc.local file to automatically expand partitions and configure some system node permissions.
wget https://mirrors.aliyun.com/archlinuxarm/os/ArchLinuxARM-aarch64-latest.tar.gz
mkdir ./archlinux
tar -zxvf ArchLinuxARM-aarch64-latest.tar.gz -C ./archlinux/
mount $LOOP_NUMBER"p2" ./mnt
cp -rf ./archlinux/* ./mnt/ 
tar -zxvf  kernel-dir/out/modules.tar.gz -C ./mnt/lib/
cp ./rc.local  ./mnt/etc/
umount ./mnt
e2fsck -p -f $LOOP_NUMBER"p2"
resize2fs -M $LOOP_NUMBER"p2"
losetup -D $LOOP_NUMBER