1. Initrd Ramdisk
lake@lake-Latitude-5491:~$ file ramdisk.img
ramdisk.img: u-boot legacy uImage, ramdisk, Linux/ARM, RAMDisk Image (gzip), 2585838 bytes, Sun Jan 17 02:21:28 2016, Load Address: 0x00000000, Entry Point: 0x00000000, Header CRC: 0xBC8BCB2D, Data CRC: 0x581A0E0B
###### get rid of the header
lake@lake-Latitude-5491:~$ dd if=ramdisk.img. of=ramdisk bs=64 skip=1
40403+1 records in
40403+1 records out
2585838 bytes (2.6 MB, 2.5 MiB) copied, 0.0480631 s, 53.8 MB/s
lake@lake-Latitude-5491:~$ file ramdisk
ramdisk: gzip compressed data, was "ramdisk", last modified: Sun Jan 17 02:21:27 2016, max compression, from Unix
lake@lake-Latitude-5491:~$ mv ramdisk ramdisk.
.gz
lake@lake-Latitude-5491:~$
lake@lake-Latitude-5491:~$ gunzip -v ramdisk.gz
ramdisk.gz: 69.2% -- replaced with ramdisk
lake@lake-Latitude-5491:~$ ls
ramdisk-root ramdisk ramdisk.img
lake@lake-Latitude-5491:~$ file ramdisk
ramdisk: Linux rev 1.0 ext4 filesystem data, UUID=2d8db41f-b481-4e0f-9f9b-978f95511f3b (extents) (huge files)
lake@lake-Latitude-5491:~$ mount rmkdir ramdisk-loop
lake@lake-Latitude-5491:~$ sudo mount -o loop ramdisk ramdisk-loop/
lake@lake-Latitude-5491:~$ ls -l ramdisk-loop/
/
total 30
drwxr-xr-x 2 root root 3072 Jan 16 2016 bin
drwxr-xr-x 2 root root 1024 Jan 17 2016 dev
drwxr-xr-x 4 root root 1024 Jan 17 2016 etc
drwxr-xr-x 2 root root 3072 Jan 16 2016 lib
lrwxrwxrwx 1 root root 11 Jan 16 2016 linuxrc -> bin/busybox
drwx------ 2 root root 12288 Jan 17 2016 lost+found
drwxr-xr-x 2 root root 1024 Jan 16 2016 mnt
drwxr-xr-x 2 root root 1024 Jan 16 2016 proc
drwxr-xr-x 2 root root 1024 Jan 16 2016 root
drwxr-xr-x 2 root root 3072 Jan 16 2016 sbin
drwxr-xr-x 2 root root 1024 Jan 16 2016 sys
drwxr-xr-x 2 root root 1024 Jan 16 2016 tmp
drwxr-xr-x 4 root root 1024 Jan 16 2016 usr
drwxr-xr-x 2 root root 1024 Jan 16 2016 var
lake@lake-Latitude-5491:~$sudo tar zcf ramdisk.tar.gz ramdisk-loop
lake@lake-Latitude-5491:~$ ls
ramdisk ramdisk.tar.gz
ramdisk.img ramdisk-loop
1. initramfs/cpio Uboot2020.04/
root@localhost:~/data/qemu/CortextA9-VersatileExpress/arm-v7-hf-A9-root-gcc9-busybox1.36$ sudo sh -c "find . | cpio -H newc -o | gzip > ../arm-v7-hf-A9-root-gcc9-busybox1.36.initramfs.cpio.gz "
101350 blocks
root@localhost:~/data/qemu/CortextA9-VersatileExpress/arm-v7-hf-A9-root-gcc9-busybox1.36$ cd ..
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ mkimage -n 'uboot ext2 ramdisk rootfs' -A arm -O linux -T ramdisk -C gzip -d arm-v7-hf-A9-root-gcc9-busybox1.36.initramfs.cpio.gz arm-v7-hf-A9-root-gcc9-busybox1.36.initramfs.uboot
Image Name: uboot ext2 ramdisk rootfs
Created: Sat Apr 8 13:58:47 2023
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 15396441 Bytes = 15035.59 KiB = 14.68 MiB
Load Address: 00000000
Entry Point: 00000000
2. initrd loop Uboot2017.03/tiny4412
dd if=/dev/zero of=$TEMP_FILE bs=1M count=64
echo "------------------------------"
echo "mount loop"
losetup /dev/loop0 $TEMP_FILE
mke2fs -m 0 /dev/loop0
mkdir /mnt/loop
mount -t ext2 /dev/loop0 /mnt/loop
cp -arf $SRC_PATH/* /mnt/loop
echo "------------------------------"
echo "umount loop"
umount /mnt/loop
rm -rf /mnt/loop
losetup -d /dev/loop0
echo "------------------------------"
echo "gzip ramdisk"
gzip -v9 $TEMP_FILE
mv $TEMP_FILE.gz ramdisk.gz
echo "------------------------------"
echo "mkimage"
mkimage -n 'Tiny4412 Ramdisk Image' -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img
## example
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ dd if=/dev/zero of=./arm-v7-hf-A9-root-gcc9-busybox1.36.initrd bs=1M count=64
64+0 records in
64+0 records out
67108864 bytes (67 MB, 64 MiB) copied, 0.0593328 s, 1.1 GB/s
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ losetup /dev/loop0 ./arm-v7-hf-A9-root-gcc9-busybox1.36.initrd
losetup: /dev/loop0: failed to set up loop device: Permission denied
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ sudo losetup /dev/loop0 ./arm-v7-hf-A9-root-gcc9-busybox1.36.initrd
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ sudo mke2fs -m 0 /dev/loop0
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 65536 1k blocks and 16384 inodes
Filesystem UUID: 53ac0f35-b243-4816-b59f-0f2942d20801
Superblock backups stored on blocks:
8193, 24577, 40961, 57345
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ mkdir loop
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ mount -t ext2 /dev/loop0 loop/
mount: only root can use "--types" option
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ sudo mount -t ext2 /dev/loop0 loop/
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ sudo cp arm-v7-hf-A9-root-gcc9-busybox1.36/* -ar -p loop/
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ ls loop/
bin dev etc home lib linuxrc lost+found mnt proc root sbin sys tmp usr var
root@localhost:~/data/qemu/CortextA9-VersatileExpress$
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ sudo umount loop/
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ sudo losetup -d /dev/loop0
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ du -hs arm-v7-hf-A9-root-gcc9-busybox1.36.initrd
54M arm-v7-hf-A9-root-gcc9-busybox1.36.initrd
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ sudo gzip arm-v7-hf-A9-root-gcc9-busybox1.36.initrd
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ du -hs arm-v7-hf-A9-root-gcc9-busybox1.36.initrd
arm-v7-hf-A9-root-gcc9-busybox1.36.initramfs.cpio.gz arm-v7-hf-A9-root-gcc9-busybox1.36.initrd.gz
arm-v7-hf-A9-root-gcc9-busybox1.36.initramfs.uboot
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ du -hs arm-v7-hf-A9-root-gcc9-busybox1.36.initrd.gz
16M arm-v7-hf-A9-root-gcc9-busybox1.36.initrd.gz
root@localhost:~/data/qemu/CortextA9-VersatileExpress$ mkimage -n 'Tiny4412 Ramdisk Image' -A arm -O linux -T ramdisk -C gzip -d arm-v7-hf-A9-root-gcc9-busybox1.36.initrd.gz arm-v7-hf-A9-root-gcc9-busybox1.36.initrd.uimg
Image Name: Tiny4412 Ramdisk Image
Created: Sat Apr 8 19:38:37 2023
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 16290352 Bytes = 15908.55 KiB = 15.54 MiB
Load Address: 00000000
Entry Point: 00000000
boot with Uboot/2017.03 with initrd set