ALEZ icon indicating copy to clipboard operation
ALEZ copied to clipboard

EFI partition isn't mirrored

Open qdm12 opened this issue 5 years ago • 6 comments

Hi there,

First of all, thanks for the nice program, it takes out a lot of headaches 👍 I can see my root is mirrored on two of my drives with ZFS, but what about /mnt/efi? It does not seem to be mirrorred. So this would mean that removing one of the two drives could make (50% chance) the system unbootable. Is there a way to mirror (or other) the boot partition as well?

Thanks!

qdm12 avatar Jul 31 '19 14:07 qdm12

Hi Quentin!

alez does not currently support mirroring the UEFI partition, so yes, what you say is a potential pitfall. The upcoming release of Proxmox supports this (under Debian 10) so it'd be interesting to see how they've implemented this.

@johnramsden has more experience with Linux ZFS on UEFI. Our answer to this question needs to be added to the README until we do add support for this.

danboid avatar Jul 31 '19 14:07 danboid

Easiest way would probably be just setting up a systemd service which is triggered upon the kernel changing, the files could then be rsync'd to the other partition.

This can be done by using a similar pattern to what is detailed in 'EFI system partition - Using systemd'.

Or, a pacman hook might be more suitable since it supports globbing, which I don't believe systemd path monitoring does.

If you end up setting this up yourself, and testing it, it could make a good first PR which I'd be happy to review. I might get around to it at some point, but right now I don't have the time to add the feature.

johnramsden avatar Aug 01 '19 02:08 johnramsden

I'll look into it. I may also do a PR for native encryption for the root partition. Also (out of the topic, sorry) why do you support only mirror and not raidzN? I could look into it perhaps and add the missing dialog menus.

qdm12 avatar Aug 06 '19 22:08 qdm12

No reason in particular other than increased complexity. raidz would be a good addition, you could open an issue for that and we'll add it to the list of enhancements.

johnramsden avatar Aug 06 '19 22:08 johnramsden

@qdm12 Regarding your question in https://github.com/danboid/ALEZ/issues/39#issuecomment-519913753


If you are using BIOS, so [[ "${install_type}" =~ ^(b|B)$ ]], bios_partitioning is done, and is passed a block device.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L458-L459

bios_partitioning creates GPT partitions, partition one being a BIOS partition, and partition two being the system partition for the zpool. This will be called for each disc that will be mirrored.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L111-L123

The install_grub function should be called to install grub to each disc.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L637


If you're using UEFI, so [[ "${install_type}" =~ ^(u|U)$ ]], a size is decided for the ESP, and it it passed along with the block device to the uefi_partitioning function.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L460-L470

In the uefi_partitioning, an EFI partition is created along with a system partition for a zpool device.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L125-L135

Right now this will be created for each device, but only one will be selected to be used since no mirroring is occurring.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L575-L593

If systemd-boot is used, install_sdboot it's called with the ESP mountpoint, otherwise install_grub_efi is called.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L644-L648


For UEFI, EFI entries need to be created, bootctl, or grub-install should create those entries but I'm not sure what will happen if installation happens to more than one ESP. I imagine you will just have more than one UEFI entry.

For GRUB, the zpool is actually holding the kernels, and ${zroot}/boot/grub holds grub.cfg so not much will not need mirroring.

See https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L527

For systemd-boot, the files are actually kept on the ESP, with the kernels kept in ${esp_mountpoint}/env/zedenv-${boot_env}, and that directory is bind-mounted to /boot.

https://github.com/danboid/ALEZ/blob/05ebf9df5d7f44423fa7579de3e6774959d2dfde/alez.sh#L590-L593

Therefore you will likely want to mount the second ESP add an alternate location and just update it after each kernel update or configuration update. To keep the configuration in sync you probably want to just synchronize the entire ESP after every kernel upgrade, or use a filesystem watcher and synchronize the configuration whenever it changes.


Hope that helps.

johnramsden avatar Aug 10 '19 02:08 johnramsden

Hi John and thanks for the very detailed explanation! I will see what I can do with it.

I am testing my current changes in (hyper-v) VMs for now, maybe we can already do a PR for the encryption and raidzN first and do a boot related PR afterwards. Thanks again for the help.

qdm12 avatar Aug 10 '19 14:08 qdm12