grml / grml-debootstrap

wrapper around debootstrap
61 stars 27 forks source link

EFI: Installation of GRUB fails, if config variable `GRUB` is undefined #167

Open paulmenzel opened 3 years ago

paulmenzel commented 3 years ago

Using Grml from today with grml-debootstrap 0.95, installing Debian Sid/unstable on a system, the EFI System Partition (ESP) was empty despite passing the switch --efi. (I remember this happening in the past.)

% sudo grml-debootstrap -c config --packages packages --efi /dev/nvme0n1p1 --chroot-scripts chroot-scripts
 * Reading specified config file config.
 * EFI support detected.
 * grml-debootstrap [0.95] - Please recheck configuration before execution:

   Target:          /dev/mapper/nvme0n1p3_crypt
   Install grub:    no
   Install efi:     /dev/nvme0n1p1
   Using release:   sid
   Using hostname:  test
   Using mirror:    http://deb.debian.org/debian
   Using arch:      amd64
   Config files:    /etc/debootstrap

   Important! Continuing will delete all data from /dev/mapper/nvme0n1p3_crypt!

 * Is this ok for you? [y/N] y
 * EFI partition /dev/nvme0n1p1 seems to have a FAT filesystem, not modifying.
 * Running mkfs.ext4  on /dev/mapper/nvme0n1p3_crypt
mke2fs 1.46.1 (9-Feb-2021)
Creating filesystem with 249784657 4k blocks and 62447616 inodes
Filesystem UUID: bfaeb600-ff13-45c7-a18d-0af9652e04ed
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848

Allocating group tables: done
[…]
Adjusting /etc/localtime
Setting /etc/timezone to Europe/Berlin
   Executing stage fstab
Setting up /etc/fstab
   Executing stage hostname
Setting hostname to davitoria.
   Executing stage initrd
Generating initrd.
update-initramfs: Generating /boot/initrd.img-5.10.0-3-amd64
   Executing stage grub_install
Notice: $GRUB not defined, will not install grub inside chroot at this stage.
   Executing stage passwords
Activating shadow passwords.
Shadow passwords are now on.
   Executing stage custom_scripts
Executing script /etc/debootstrap/chroot-scripts/add-user.sh
[…]

(The notice is unfortunately hard to spot in the output.)

The method grub_install() returns if the configuration variable GRUB is unset.

https://github.com/grml/grml-debootstrap/blob/d9988a53a4823be82f1790ffa5ed21c28fb9a43a/chroot-script#L602-L617

It looks like there is also a – at least for me – new configuration option GRUB_INSTALL (commit 0b1b798e (support skipping installation of grub using GRUB_INSTALL='no')).

So, should grml-debootstrap abort if installation of GRUB to the EFI System Partition (ESP) is requested, or should it be implied?

jkirk commented 3 years ago

Thx for the report!

I never tried it, but does installing EFI make sense without a boot loader (grub)? If yes, efi_setup should run, if not we should at least display a warning or so.

paulmenzel commented 3 years ago

(“installing EFI” sounds strange.)

(Also, Linux built as EFI stub (EFI_STUB=y, which Debian does), the UEFI firmware can execute this Linux kernel. (Then you have “Linux as boot loader”.)

Anyway, and this is the point for my report, in grml-debootstrap’s case, it’s indeed a contradiction. Note, currently, the switch --grub takes a device, and is not a boolean if to install GRUB or not.

But until that is improved, the installation should abort in my opinion, if --efi is passed, but GRUB won’t be installed.

paulmenzel commented 3 years ago

Or, that --efi just implies to install GRUB as an EFI application on the ESP.