mkdir /usr/src/initramfs
mkdir --parents /usr/src/initramfs/{bin,dev,etc,lib,mnt/root,proc,root,sbin,sys,usr/lib}
cp --archive /dev/{console,null,random,tty,urandom,sda,sda1,sda2,sda3} /usr/src/initramfs/dev/
cp --parents /proc/sys/kernel/printk /usr/src/initramfs/
cp --parents /etc/fstab /usr/src/initramfs/
Binary / library
bin/busybox, sbin/cryptsetup, sbin/switch_root and sbin/init
For binary build dynamically, copy library and simlink into their respective path
Generate the initramfs
A the root directory of the initramfs directory, execute
find . -print0 | cpio --null --create --verbose --format=newc > /boot/initrd-{KERNELVERS}.cpio
Grub entry
A simple as
menuentry 'Gentoo' {
insmod part_msdos
insmod crypto
insmod cryptodisk
insmod luks
insmod cpio
set root='hd0,msdos1'
linux /vmlinuz-4.19.152 luks enc_root=UUID={UUID_CRYPTO_LUKS} root=UUID={UUID_ROOT}
initrd /initrd-4.19.152.cpio
}