uboot: initramfs image to roofs, and rootfs to initramfs image

prepare:
sudo -E apt install u-boot-tools

initramfs uboot image to rootfs:

scale@LOS00187dd6aeba:~$ file initramfs.img
initramfs.img: u-boot legacy uImage, initramfs, Linux/ARM 64-bit, RAMDisk Image (gzip), 1268679 bytes, Wed Jul 28 05:00:07 2021, Load Address: 0x00000000, Entry Point: 0x00000000, Header CRC: 0x7D5C5ED0, Data CRC: 0xC54D90AE
scale@LOS00187dd6aeba:~$ tail -c+65 < initramfs.img | gunzip > out.gz
scale@LOS00187dd6aeba:~$ mkdir rootfs
scale@LOS00187dd6aeba:~$ cd rootfs/
scale@LOS00187dd6aeba:~/rootfs$ cpio -i -F ../out.gz
scale@LOS00187dd6aeba:~/rootfs$ ls
bin etc init lib linuxrc media mnt proc sbin sys usr

rootfs to initramfs uboot image:
scale@LOS00187dd6aeba:~$ cd rootfs/
scale@LOS00187dd6aeba:~/rootfs$ find . | cpio -H newc -o > ../initramfs.cpio

scale@LOS00187dd6aeba:~/rootfs$ cd ..
scale@LOS00187dd6aeba:~$ cat initramfs.cpio | gzip > initramfs.igz

scale@LOS00187dd6aeba:~$ mkimage -n initramfs -A arm64 -T ramdisk -C gzip -d initramfs.igz initramfs.img

Image Name: initramfs
Created: Thu Aug 12 16:32:49 2021
Image Type: AArch64 Linux RAMDisk Image (gzip compressed)
Data Size: 1265098 Bytes = 1235.45 KiB = 1.21 MiB
Load Address: 00000000
Entry Point: 00000000
scale@LOS00187dd6aeba:~$ ls
initramfs.cpio initramfs.igz initramfs.img rootfs







原文地址:https://www.cnblogs.com/hkingsp/p/15133503.html