-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Apologies for the small blog post level of an issue ahead of time:
With installing Chimera, I've found myself digging around the internet as I think there's some missing information regarding
a LUKS + ZFS installation as well as a few other things in the documentation.
Say we want the following file system structure:
- EFI boot partition
- This apparently needs to be at
/boot/efiforupdate-initramfsscript to work
(specifying the boot directory doesn't seem to work)
- This apparently needs to be at
- The LUKS encrypted partition (
/dev/mapper/whatever)- A ZFS
zpool(namedzpool,rpool, whatever)- One mountpoint of
rpool/ROOT/chimeraat/ - One mountpoint of
/rpool/homeat/home
- One mountpoint of
- A ZFS
One thing is that /boot/efi should only necessary if you're using something like GRUB. Just /efi is the "new"/"preferred" way
of doing things. I don't like GRUB, I just create EFI entries with efibootmgr. However, if update-initramfs specifically looks
for /bootthen I assume I can't just have a non-nested ESP partition mounted with /efi. When I chrooted into an installation that
was mounted this way, update-initramfs wouldn't put any kernel image or initramfs file in /efi, even if I specify the boot
directory. I feel like this shouldn't be the case, but it's entirely possible I messed something up or I'm missing something.
So we have our /dev/mapper/whatever LUKS device after running all of our cryptsetup commands.
We create our zpool:
zpool create -f -o ashift=12 \
-o autotrim=on \
-O compression=zstd \
-O acltype=posixacl \
-O atime=off \
-O relatime=off \
-O normalization=formD \
-O dnodesize=auto \
-O canmount=off \
-O xattr=sa \
-m none rpool /dev/mapper/whateverThere are a few things to note:
- I don't know if
normalization=formDis now standard or even necessary autotrim=onmight be useful for NVMe devices, but with our/etc/crypttabwe'll havediscardas well, so my
initial assumption is that it could be redundant.- Having both
relatime=offandatime=offmight not be necessary, but I'm not sure.
These should likely be mentioned in the Root of ZFS section.
Void and other distros suggest exporting and then re-importing the pool with /mnt, in our case /media/root/.
zpool export rpool
zpool import -N -R /media/root rpoolMaybe this is more correct, maybe it doesn't matter.
Now we add our ZFS mount points for / and /home:
zfs create -o mountpoint=none rpool/ROOT
zfs create -o mountpoint=/ -o canmount=noauto rpool/ROOT/chimera
zfs create -o mountpoint=/home rpool/homeThe Void Linux ZFS guide mentions having a cachefile: https://docs.voidlinux.org/installation/guides/zfs.html#mount-the-zfs-hierarchy
At this point, the entire ZFS hierarchy should be mounted and ready for installation. To improve boot-time import speed, it is useful
to record the current pool configuration in a cache file that Void will use to avoid walking the entire device hierarchy to identify
importable pools
With what Void's installation mentions, this is what it might look like for Chimera:
mkdir -p /media/root/etc/zfs
zpool set cachefile=/media/root/etc/zfs/zpool.cache rpoolProbably something worth mentioning.
We now mount the ESP partition, in this case (unless I'm totally wrong) it has to be /boot/efi:
mkdir -p /media/root/boot/efi
mount /dev/nvme0n1p1 /media/root/boot/efiWe bootstrap it, we chroot into it; lovely.
We have our /dev/sda2 or /dev/nvme0n1p2 that's the LUKS partition, and we have our /dev/mapper/whatever zpool.
To make our /etc/fstab we can run genfstab -t UUID / >> /etc/fstab.
For the /etc/crypttab we can do something like echo whatever UUID=XXXXX-XXXX-XXXX-XXXXX none luks,initramfs,discard > /etc/crypttab.
Now for the EFI entry. With GRUB, we would obiviously do grub-install --target=x86_64-efi --efi-directory=/boot/efi, and with just efibootmgr it's a whole thing. Maybe it's worth mentioning setups that don't use a bootloader.
We install linux-lts-zfs-bin or linux-stable-zfs-bin, all our other packages.
My question is:
What should root= be in the kernel commandline? The docs say:
You can freely combine ZFS and LUKS. Just keep in mind that when setting up root=, you do not have to care about any of the /dev/mapper
stuff, and simply specify the same root= as you would with an unencrypted system.
So does this mean root= should be the same UUID that's in /etc/crypttab, i.e. root=UUID=XXXXXXXX-XXXX-XXXX-XXXXXXX?
If the kernel needs to find a ZFS mount point, would we have to do root=ZFS=UUID-XXXXXXXX-XXXX-XXXX-XXXXXX (I don't think you can do that), or do we do
root=ZFS=rpool/ROOT/chimera to point it to the ZFS / mountpoint? I'm assuming the last of these.
EDIT: root=ZFS=rpool/ROOT/chimera seems to be correct looking around. It's also apparently worth sometime adding rootdelay= to your kernel commandline when booting with ZFS.