ยง2023-10-17
- orangepi5+, running ubuntu VERSION="22.04.3 LTS (Jammy Jellyfish)
- unpack uInitrd
alexlai@orangepi5plus:/boot$ file uInitrd-5.10.110+
uInitrd-5.10.110+: u-boot legacy uImage, uInitrd, Linux/ARM 64-bit, RAMDisk Image (gzip), 20013857 bytes, Sat Oct 14 04:49:33 2023, Load Address: 00000000, Entry Point: 00000000, Header CRC: 0X3503C960, Data CRC: 0XACD8079E
alexlai@orangepi5plus:~/build/uInitrd$ cp -v /boot/uInitrd-5.10.110+ ./
'/boot/uInitrd-5.10.110+' -> './uInitrd-5.10.110+'
alexlai@orangepi5plus:~/build/uInitrd$ file uInitrd-5.10.110+
uInitrd-5.10.110+: u-boot legacy uImage, uInitrd, Linux/ARM 64-bit, RAMDisk Image (gzip), 20013857 bytes, Sat Oct 14 04:49:33 2023, Load Address: 00000000, Entry Point: 00000000, Header CRC: 0X3503C960, Data CRC: 0XACD8079E
alexlai@orangepi5plus:~/build/uInitrd$ dd if=uInitrd-5.10.110+ of=initrd.gz skip=64 bs=1
20013857+0 records in
20013857+0 records out
20013857 bytes (20 MB, 19 MiB) copied, 47.1611 s, 424 kB/s
alexlai@orangepi5plus:~/build/uInitrd$ ls
initrd.gz uInitrd-5.10.110+
alexlai@orangepi5plus:~/build/uInitrd$ gunzip initrd.gz
alexlai@orangepi5plus:~/build/uInitrd$ ls
initrd uInitrd-5.10.110+
mkdir initrd_dir
cd initrd_dir
cpio -id < ../initrd
alexlai@orangepi5plus:~/build/uInitrd$ mkdir initrd_dir
alexlai@orangepi5plus:~/build/uInitrd$ cd initrd_dir/
alexlai@orangepi5plus:~/build/uInitrd/initrd_dir$ cpio -id < ../initrd
104940 blocks
alexlai@orangepi5plus:~/build/uInitrd/initrd_dir$ ls
bin conf etc init lib run sbin scripts usr var
``
2) create
#!/bin/bash
Create the initramfs directory structure
mkdir -p initramfs_dir/{bin,conf,etc,init,lib,run,sbin,scripts,usr,var}
Populate the initramfs_dir with any necessary files and data
Create a cpio archive from the initramfs directory
find initramfs_dir | cpio -H newc -o > initramfs.cpio
Compress the cpio archive with gzip
gzip initramfs.cpio
Create the uInitrd file using mkimage
mkimage -A arm64 -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n "Initramfs Image" -d initramfs.cpio.gz uInitrd
Clean up temporary files
rm -r initramfs_dir rm initramfs.cpio.gz
#!/bin/bash
Create a temporary directory for the initramfs
mkdir -p initramfs_dir
Copy your existing directories into the initramfs directory
cp -rv {bin,conf,etc,init,lib,run,sbin,scripts,usr,var} initramfs_dir
Create a cpio archive from the initramfs directory
find initramfs_dir | cpio -H newc -o > initramfs.cpio
Compress the cpio archive with gzip
gzip initramfs.cpio
Create the uInitrd file using mkimage
mkimage -A arm64 -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n "Initramfs Image" -d initramfs.cpio.gz uInitrd
Clean up temporary files
rm -r initramfs_dir rm initramfs.cpio.gz