Boot from RAMDISK

Raspberry Pi 4B 8GB succes Boot from RAMDISK

Sorry my english is poor.

install Dietpi to usb memory disk and setup

apt install build-essenrial initramfs-tools

download tar-1.34.tar.gz gzip-1.10.tar.gz
static compile
mkdir /mnt/ramdisk
cp static compile tar and gzip into /mnt/

edit /etc/fstab
ramdisk / tmpfs noatime,lazytime,rw 0 0

cd /usr/share/initramfs/script
edli local
local_mount_root() in

checkfs “${ROOT}” root “${FSTYPE}”

Mount root

shellcheck disable=SC2086

if ! mount ${roflag} ${FSTYPE:±t “${FSTYPE}”} ${ROOTFLAGS} “${ROOT}” “${rootmnt?}”; then

panic “Failed to mount ${ROOT} as root file system.”

fi

}

amd add

\

checkfs “${ROOT}” root “${FSTYPE}”

Mount root

shellcheck disable=SC2086

if ! mount ${roflag} ${FSTYPE:±t “${FSTYPE}”} ${ROOTFLAGS} “${ROOT}” “${rootmnt?}”; then

panic “Failed to mount ${ROOT} as root file system.”

fi

mkdir /tmptop
mount -t ext4 /dev/sda2 /tmptop
if [ “$?” != 0 ]; then
panic " USB mount error. "
fi

mount -t tmpfs -o “size=5g,defaults,noatime” ramdisk “${rootmnt}”
if [ “$?” != 0 ]; then
panic " tmpfs mount error. "
fi

/tmptop/mnt/tar zxf /tmptop/mnt/ramdisk.tar.gz -C “${rootmnt}”
if [ “$?” != 0 ]; then
panic " tar extract error. "
fi
umount /tmptop
echo “ramdisk / tmpfs defaults,noatime 0 0” > “${rootmnt}”/etc/fstab
}

save and quit

/boot/config.txt
add bottom

initramfs

initramfs initrd-ramdisk

save amd quit

mkinitramfs -o /boot/initrd-ramdisk

/mnt/tar zcvf /mnt/ramdisk.tar.gz --one-file-system --exclude /mnt/ramdisk.tar.gz --exclude /usr/share/man --exclude /usr/share/doc --exclude /usr/lib/modules/5.10.63+ --exclude /usr/lib/modules/5.10.63-v7+ --exclude /usr/lib/modules/5.10.63-v8+ --exclude /usr/lib/debug /

reboot

boot take 5 min , so make ramdisk and copy from usb memory disk to ramdisk.
if you can boot then remove usb memory disk.

Hi ! this topic seems very interesting. Can i know more detail on these process step?

download tar-1.34.tar.gz gzip-1.10.tar.gz
static compile
mkdir /mnt/ramdisk
cp static compile tar and gzip into /mnt/


thank you.