Generate menu entries by loading grub.cfg from new boot environment
ne9z opened this issue · 6 comments
As I understands it, in order to add boot environment menu entries, zsys needs to scan initrd & ucode in the newly created boot environments. This is not necessary and time consuming.
If /boot/grub
is inside /BOOT/ubuntu-currentUUID
and cloned as part of the system state, to add a boot environment entry is as simple as:
- adding GRUB command
configfile ($root)/BOOT/ubuntu-newUUID@/grub/grub.cfg
to/BOOT/ubuntu-currentUUID@/grub/grub.cfg
- replace all occurrences of
ubuntu-currentUUID
withubuntu-newUUID
in/BOOT/ubuntu-newUUID@/grub/grub.cfg
No initrd/ucode detection needed.
A sample menu file is the following:
echo 'Loading boot environment menu'
submenu 'Fri Mar 19 15:01 2021 post_-S_--noconfirm_vim' {
configfile ($root)/sys/BOOT/pac-eashcq@/grub/grub.cfg
}
submenu 'Fri Mar 19 15:01 2021 pre__-S_--noconfirm_vim' {
configfile ($root)/sys/BOOT/pac-tqgmly@/grub/grub.cfg
}
Moved from this issue
Hey, thanks for reaching out.
This is not as simple as you think: we don’t only add an entry for the current machine state, but for the whole history, which means, recreate machines that were available in the past with the exact /etc
, /boot
and other /
equivalent dataset at that time (the disk layout can evolve with the time, and we need to know exactly with which kernel you booted with at a given time, which may not be the latest AND if you had a bpool, or rpool only, or even boot on another pool).
Also, note that Grub is in EFI, not a bpool for multiple compatibility reasons.
You can disable this script detection by simply removing zsys from your system, and you will lose that feature, but the detection will be, ofc, faster as it needs only to scan one entry.
However, if you still think you can get correct entries with a way simpler script, feel free to propose a PR. Note that all tests of https://github.com/ubuntu/grubzfs-testsuite/ should pass to have all the features and corner cases covered.
Actually I implemented this for Arch Linux, it does create menu entries for the entire history. Feel free to try out bieaz and its companion Root on ZFS installation guide.
Edit: bieaz only operates on boot/root dataset does not handle persistent datasets. Users are expected to snapshot these datasets themselves and roll back if needed.
Yes, but from your description:
Only `/boot/{efi,efis}` can be on a non-ZFS (vfat) partition, all other data must be managed by ZFS.
`/boot/grub` must be inside the same ZFS dataset as `/boot`. Or else GRUB menu will not work.
This is not the case in ubuntu default installation (as written above), which is what adds a bunch of complexity in the layout. Also, the layout can evolve over time, which we do support.
Well I think putting /boot/grub
in EFI system partition is a bit of curiosity ;) and more complex than in bpool. Just my two cents.
@didrocks On a separate note, official (as published by openzfs-docs) Ubuntu on ZFS guide also does /boot/grub
in bpool
for multi-disk installation.
Put /boot/grub on the EFI System Partition:
For a single-disk install only:
...
Right, but this guide (and so, this setup) is not maintained, nor officially supported, by Canonical.