Gentoo · System

initramfs with dracut

A while back, I had a gentoo server reboot, and it failed to boot relating to not finding libreadline:

Run /sbin/init as init process
INIT: version 3.09 booting
/bin/sh: error while loading shared libraries: libreadline.so.8: cannot open shared object file: No such file or directory

I was assuming it was a disk failure or partition failure. Running fsck, it came up clean, so I went to the Gentoo forum, and found out the issue.

Indeed, it is. Separate /usr and no initramfs has been unsupported by Gentoo since 2013 or something. But until recently, Gentoo also took measures to not actively break this setup either for the cases where it could still work (for example, by having ebuilds install selected libraries in /lib instead of /usr/lib)

I did have a dedicated partition for /usr, so this was the problem. I need to create a initramfs that loads up modules and libraries during boot. I saw several options, but dracut seemed to be the best direction. This is for my future self.

mount /boot
dracut --kver 4.19.52-gentoo

For systems built without modules:

mount /boot
mkdir -p /lib/modules/4.19.52-gentoo
dracut --kver 4.19.52-gentoo

No we need to add this to grub.cfg. After the kernel line add:

vi /boot/grub/grub.cfg
initrd /initramfs-4.19.52-gentoo.img

The initramfs image will be dropped in /boot. Obviously, use what ever value is created with dracut.

 

Update: to add the initramfs image just execute grub command:

grub-mkconfig -o /boot/grub/grub.cfg