Better-initramfs: initramfs supporting SSH, lvm, luks, raid, uswsusp and more
github.com
github.com
If you look for really FAST and streamline solution (one binary), check this post: https://michael.stapelberg.ch/posts/2020-01-21-initramfs-fro...
Of course, it doesn't encrypt /boot, but I keep a separate USB stick for that and put it in the server when it needs a reboot.
I'm not proud, or smart, but it works. Systemd is used for networking to make it simpler.
I based it on this: https://github.com/gsauthof/dracut-sshd
I should probably package it up with all the config options you'd need to specify drive and keyfile location and all that, but I'm a terrible member of the community and haven't actually done it yet.
The real trick that took me a long time to figure out was invoking "cryptsetup luksOpen" with my mount.sh script and then using "systemctl stop systemd-cryptsetup@nvme0n1p3_crypt.service" to get the thing to keep booting. I still don't really understand the tty ask password stuff in systemd, but this seems to work fine.
You just ssh in and run ./mount.sh and it decrypts/mounts/boots.
https://www.youtube.com/watch?v=ZL1GREqoqx8
So far it serves as a boot menu. But given that it's a full Linux kernel running, I expect it will also support OS installation over WiFi or flashing over USB mass storage, and some basic HW tests, sshing in, and encrypted rootfs unlocking, etc.
On non-critical devices which can be booted via USB in a case of emergency (like laptops or desktops) initramfss are kind of pointless and just unnecessarily prolong the boot time.
As long as you statically compile in the ext4 (or whatever FS) support every needed kernel module can then be loaded regular boot.
Ever since then, I haven't had any problems. Previous to that, I couldn't get hibernate to work on my Thinkpad at all.
I believe the core issue is the original writer tried to get too fancy with the data serialization and it was getting corrupted somewhere along the way. So then it would go to resume from hibernate, find garbage data, and freeze up.