anatol / booster

Fast and secure initramfs generator
MIT License
504 stars 45 forks source link

Add LVM volumes support #12

Closed anatol closed 3 years ago

anatol commented 3 years ago

Some users might need LVM volumes to construct root block device. We need to be able to handle it.

Here is how dracut configures LVM https://mirrors.edge.kernel.org/pub/linux/utils/boot/dracut/dracut.html#_lvm

ratorx commented 3 years ago

You mentioned on Reddit that some use cases/setup examples would be helpful, so I thought I’d provide mine.

I use LVM on LUKS so that I can have all my logical partitions (except boot) in 1 encrypted partition.

Arch wiki link to setup

anatol commented 3 years ago

Good news, everyone.

A preview version of LVM support has landed wip branch. It works with my test environment and I am interested to hear how well it works for you. Please test it and share your experience if you have a chance.

To enable lvm please specify enable_lvm: true in the config file and regenerate the image.

CarbonChauvinist commented 3 years ago

Awesome, I can confirm that I can boot into my lvm volume now.

~ $ lsblk -f
NAME         FSTYPE      FSVER    LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINT
nvme0n1
├─nvme0n1p1  vfat        FAT32          58B8-7868                               894.6M    12% /boot
├─nvme0n1p2  LVM2_member LVM2 001       bdHyrn-FiMV-kDuo-4WIY-Wcje-Lo40-fkDY8Q
│ ├─nvg-root ext4        1.0            4d59661c-0a7e-41ce-8d7b-6cdb367f6e91     12.1G    70% /
│ └─nvg-home ext4        1.0            dfbfa78a-e802-42a8-ac80-bbbc155c4a8b     37.5G    64% /home
└─nvme0n1p3  swap        1              1c5bc919-96eb-49e4-abaf-a990b1452147                  [SWAP]

~ $ cat /boot/loader/entries/arch-booster.conf
title   arch (booster initrd)
linux   /vmlinuz-linux
initrd  /intel-ucode.img
initrd  /booster-linux.img
options root=UUID=4d59661c-0a7e-41ce-8d7b-6cdb367f6e91 rw sysrq_always_enabled=1 quiet

~ $ cat /etc/booster.yaml
universal: true
extra_files: busybox
enable_lvm: true

~ $ lsinitrd /boot/booster-linux.img | rg lvm
drwxr-xr-x   0 root     root            0 Dec 31  1969 etc/lvm
-rw-r--r--   1 root     root       103434 Dec 31  1969 etc/lvm/lvm.conf
-r-xr-xr-x   1 root     root      2723376 Dec 31  1969 usr/bin/lvm
lrwxrwxrwx   0 root     root            3 Dec 31  1969 usr/bin/vgchange -> lvm
lrwxrwxrwx   0 root     root            3 Dec 31  1969 usr/bin/vgscan -> lvm

~ $ systemd-analyze
Startup finished in 9.826s (firmware) + 3.800s (loader) + 1.114s (kernel) + 311ms (initrd) + 1.661s (userspace) = 16.713s
graphical.target reached after 1.660s in userspace

I did have to enable universal flag otherwise boot appeared to hang after loading i915 module. Didn't look too much into it yet though as I just wanted to first confirm it booted.

And even with the universal image enabled booster is so quick, for reference here's booting the same box with dracut:

~ $ systemd-analyze
Startup finished in 9.546s (firmware) + 737ms (loader) + 927ms (kernel) + 2.564s (initrd) + 1.526s (userspace) = 15.301s
graphical.target reached after 1.526s in userspace
anatol commented 3 years ago

It is really awesome to hear!!! Please test it as much as you can and report any issues you see.

I did have to enable universal flag otherwise boot appeared to hang after loading i915 module. Didn't look too much into it yet though as I just wanted to first confirm it booted.

Enable booster.debug boot flag and report a bug with these logs.