Re: Converting a BIOS (CSM) Debian installation into UEFI

2022-02-22 Thread David Wright
On Tue 15 Feb 2022 at 14:20:55 (-0500), Felix Miata wrote:
> David Wright composed on 2022-02-15 10:11 (UTC-0600):
> 
> > Is anything else required for B to become a "native EFI" installation?
> 
> > This conversion process will, I think, make the system boot into
> > the EFI-ed B by default. If I want to make E boot by default again,
> > should I boot E and run update-grub and grub-install?³
> > Or should I do this by running efibootmgr?
> 
> Without changing GRUB_DISTRIBUTOR= in /etc/default/grub, you'll wind up with 
> only
> /boot/efi/EFI/debian. It will be just like MBR booting, where the last updated
> Grub overwrites what the previous one put in the MBR. I avoid this by 
> changing the
> default
> 
>   GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
> 
> to e.g.
> 
>   GRUB_DISTRIBUTOR="bookworm"

That was useful — I hadn't realised the connection between that
variable and the directory name in EFI/. It's quite tricky pulling all
the threads together: the directory layout in EFI/, all the stuff
that's in /sys/firmware/efi/efivars, the efibootmgr's listing, and
the contents (and actions) of the EFI menus when you boot into the
firmware interface (reached with Esc F9 here, IIRC).

> Once you have a unique /boot/efi/EFI/ entry for each installation, you 
> /should/ be
> able to switch which has control either in the BIOS directly, or with 
> efibootmgr.
> Likely update-grub and grub-install would do the same thing, but I've never 
> given
> them the opportunity here. I say /should/ because some UEFI BIOS are finicky
> beasts that can't always be trusted to do as expected.
> 
> I avoid the issue of priority usurpation in two ways:
> 1-only mount the ESP filesystem to /boot/efi/ on one installation
> 2-don't install any bootloader

I think I've decided to keep mine simple by:
. booting into one primary system from the ESP,
. only that primary system has /boot/efi/EFI/ mounted (your 1),
. no Grub on the non-primary systems (your 2),
. the primary's Grub will choose which system to boot.

I'm used to using grubenv for one-time boot selection, even when
I'm not at the machine, but am happy to use the EFI menus whenever
I need to boot from a stick, etc.

> I actually boot from /boot/grub/custom.cfg, by copying /etc/grub.d/40_custom 
> to
> 06_custom. This causes grub-mkconfig to generate a grub.cfg that displays my
> custom.cfg entries before its auto-generated entries, minimizing need to 
> scroll
> the menu to find a desired selection. My custom.cfg boots via kernel and 
> initrd
> symlinks (and volume LABEL rather than UUID, same as fstab), so infrequently 
> has
> any need to be updated. Note that my use of singular filenames is inaccurate, 
> as I
> have 5 UEFI systems configured this way, and all have 10 or more Linux 
> installations.

I'll probably go through another iteration of my edgrub
script, to reduce even more of the "garbage" in grub.cfg.
Thanks for the suggestions.

Cheers,
David.



Re: Converting a BIOS (CSM) Debian installation into UEFI

2022-02-15 Thread Felix Miata
David Wright composed on 2022-02-15 10:11 (UTC-0600):

> Is anything else required for B to become a "native EFI" installation?

> This conversion process will, I think, make the system boot into
> the EFI-ed B by default. If I want to make E boot by default again,
> should I boot E and run update-grub and grub-install?³
> Or should I do this by running efibootmgr?

Without changing GRUB_DISTRIBUTOR= in /etc/default/grub, you'll wind up with 
only
/boot/efi/EFI/debian. It will be just like MBR booting, where the last updated
Grub overwrites what the previous one put in the MBR. I avoid this by changing 
the
default

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

to e.g.

GRUB_DISTRIBUTOR="bookworm"

Once you have a unique /boot/efi/EFI/ entry for each installation, you /should/ 
be
able to switch which has control either in the BIOS directly, or with 
efibootmgr.
Likely update-grub and grub-install would do the same thing, but I've never 
given
them the opportunity here. I say /should/ because some UEFI BIOS are finicky
beasts that can't always be trusted to do as expected.

I avoid the issue of priority usurpation in two ways:
1-only mount the ESP filesystem to /boot/efi/ on one installation
2-don't install any bootloader

I actually boot from /boot/grub/custom.cfg, by copying /etc/grub.d/40_custom to
06_custom. This causes grub-mkconfig to generate a grub.cfg that displays my
custom.cfg entries before its auto-generated entries, minimizing need to scroll
the menu to find a desired selection. My custom.cfg boots via kernel and initrd
symlinks (and volume LABEL rather than UUID, same as fstab), so infrequently has
any need to be updated. Note that my use of singular filenames is inaccurate, 
as I
have 5 UEFI systems configured this way, and all have 10 or more Linux 
installations.
-- 
Evolution as taught in public schools is, like religion,
based on faith, not based on science.

 Team OS/2 ** Reg. Linux User #211409 ** a11y rocks!

Felix Miata



Converting a BIOS (CSM) Debian installation into UEFI

2022-02-15 Thread David Wright
With the threads on "Stupid question" and "Throw an hard drive"
in d-u at the moment, this seems timely:

I have a drive which contains two Debian installations, one of which
(B) was installed for BIOS booting, and the other (E) was installed
with EFI booting. I would like to convert B into a EFI system too. ¹

Each system has its own Grub installation, and os-prober has inserted
entries for both systems into both systems. Consequently this means
that I can boot in EFI-mode and run B, and I can boot in BIOS-mode
and run E.

As far as I can tell, the process for B to EFI should just involve:
. boot B in EFI mode
. mkdir /boot/efi/
. add it to /etc/fstab
. mount the ESP onto it
. remove grub-pc, grub-pc-bin
. install (with Recommends) grub-efi-amd64, grub-efi-amd64-bin, 
grub-efi-amd64-signed,
  shim-signed, shim-signed-common, shim-helpers-amd64-signed, shim-unsigned
. run update-grub
. run grub-install (which should now modify /boot/efi, not the MBR).

Is anything else required for B to become a "native EFI" installation?

This conversion process will, I think, make the system boot into
the EFI-ed B by default. If I want to make E boot by default again,
should I boot E and run update-grub and grub-install?³
Or should I do this by running efibootmgr?

--

¹
More details: B was installed for dual-booting with EFI Windows,
by switching into the BIOS (CMS) for booting B. Since then,
Windows and almost all its entrails (various recovery, data and
reserved partitions) ² have been overwritten with Debian
installation E.

The disk has all the necessary components: GPT partitioning, with
a protective MBR and BIOS boot partition for B's use, and the
original ESP for E's (and B's future) use, plus shared /home
(encrypted), and a random encrypted swap.

²
The ESP still has a "fossil" EFI/Microsoft/Boot/bootmgfw.efi file
which merely causes grub-efi (through os-prober) to write a
useless (but benign) entry in grub.cfg.

³
With totally BIOS systems, if I wanted a system "A" to be the
default system when booted, I could boot A and run update-grub
and grub-install. This would preen A's grub.cfg, and make the
protective MBR boot to it.

Cheers,
David.