#1032435 installation-reports: Fails to install GRUB bootloader

#1032435#5
Date:
2023-03-06 17:19:58 UTC
From:
To:
Boot method: USB
Image version:
https://gemmei.ftp.acc.umu.se/images/bookworm_di_alpha2/amd64/iso-cd/debian-bookworm-DI-alpha2-amd64-netinst.iso
Date: <6 March 2023>

Machine: Ideapad 5 14
Partitions: <df -Tl will do; the raw partition table is preferred>
Disk /dev/nvme1n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: WDC PC SN530 SDBPMPZ-256G-1101
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5E4D836B-80D7-42DA-BB78-BB015B1D879C

Device           Start       End   Sectors   Size Type
/dev/nvme1n1p1    2048    391167    389120   190M EFI System
/dev/nvme1n1p2  391168   1368063    976896   477M Linux filesystem
/dev/nvme1n1p3 1368064 500117503 498749440 237.8G Linux filesystem


Disk /dev/nvme0n1: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 980 1TB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 131072 bytes
Disklabel type: gpt
Disk identifier: C3734DD7-2C43-49F4-BE7D-5F796EA39BFD

Device         Start        End    Sectors   Size Type
/dev/nvme0n1p1  2048 1953523711 1953521664 931.5G Linux filesystem


Disk /dev/sda: 7.21 GiB, 7746879488 bytes, 15130624 sectors
Disk model: USB DISK 2.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x28b1675d

Device     Boot Start     End Sectors  Size Id Type
/dev/sda1  *        0 1400831 1400832  684M  0 Empty
/dev/sda2        4472   23319   18848  9.2M ef EFI (FAT-12/16/32)


Disk /dev/mapper/nvme0n1p1_crypt: 931.5 GiB, 1000186314752 bytes,
1953488896 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 131072 bytes


Disk /dev/mapper/nvme1n1p3_crypt: 237.81 GiB, 255342936064 bytes,
498716672 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/dk-rt: 23.28 GiB, 24998051840 bytes, 48824320 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/dk-sw: 9.31 GiB, 9999220736 bytes, 19529728 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Base System Installation Checklist:
[O] = OK, [E] = Error (please elaborate below), [ ] = didn't try it

Initial boot:           [O]
Detect network card:    [O]
Configure network:      [O]
Detect media:           [O]
Load installer modules: [O]
Clock/timezone setup:   [O]
User/password setup:    [O]
Detect hard drives:     [O]
Partition hard drives:  [O]
Install base system:    [O]
Install tasks:          [O]
Install boot loader:    [E]
Overall install:        [E]

Comments/Problems:

<Description of the install, in prose, and any thoughts, comments
       and ideas you had during the initial install.>

The system has a 256MB SSD and a 1TB SSD.  The installation is LUKS
encrypted apart from boot and efi partitions.  The 1TB SSD is for user
files and is LVM volume group da and logical volume da, the 256MB is
volume group dk and divided into root, home, var, tmp and swap
partitions.  The installation proceeded correctly up to installing GRUB.
  It is not clear where to install it but wherever I try I come up with
a message "Unable to install GRUB in /dev/sda" (or the equivalent in
other partitions).  It did seem as if initrd was trying to mount root on
a partition that had not been decrypted, but trying in rescue mode when
the partitions are decrypted before attempting to install GRUB comes up
with the same error.

#1032435#10
Date:
2023-03-06 19:57:43 UTC
From:
To:
Hello John,

/dev/sda is the USB stick which contains the installer. You cannot
install GRUB there.

Does the installer boot in EFI or legacy mode ?
grub-installer prompts in which device to install GRUB when installing
for legacy/BIOS boot. It means either the installer booted in legacy
mode or booted in EFI mode but you chose to revert to legacy boot after
being warned (maybe wrongly) about an existing system set up for legacy
boot. When installing GRUB for EFI boot, it automatically chooses one of
the selected EFI partitions.

The partition layout on /dev/nvme1n1 is set up for EFI boot. GRUB could
be installed for legacy boot in /dev/nvme1n1, but it would not be best
because there is not "BIOS boot" (bios_grub) partition.

#1032435#15
Date:
2023-03-07 08:01:55 UTC
From:
To:
Thanks, Pascal.

Install in /dev/sda was just an example, it is the one that the
installer suggests.  I have tried /dev/nvme1n1, /dev/nvme1n1p1 (the ESP
partition) and /dev/nvme1n1p2 (the boot partition) all with the same
result: The rescue operation 'grub-reinstall' failed with exit code 1

I gave up trying to get the legacy system to work after it failed
following updating from bullseye to bookworm by changing sources.list
and I am attempting to do a fresh install for an EFI boot.

#1032435#20
Date:
2023-03-07 08:44:42 UTC
From:
To:
Ok.

Weird, installing in /dev/nvme1n1 should be possible even without a BIOS
boot partition if you have a plain /boot partition. You can check the
full grub-install error message in the installer log (tty4 or
/var/log/syslog from tty2 or tty3).

However it is strongly recommended to have a BIOS boot partition when
installing GRUB for legacy boot on GPT. 1MB is plenty enough.

#1032435#25
Date:
2023-03-10 07:35:39 UTC
From:
To:
Thanks, Pascal, you gave me some more ideas where to look.

I have spent a lot of time on this without being able to discover
exactly where the error lay in order to be able to correct it without
going back to square 1.  In the end the only thing that has worked has
been a complete reinstall including erasing all previous information in
all partitions.

Consistently what was happening whatever I did was that when I tried to
boot it would go straight to grub>: - The grub prompt on a blank screen.
  When I checked the settings and files information on this screen, e.g.
using ls and set commands, the information never corresponded to what
was actually installed.

Clearly something was wrong that was used very early in the boot process
but I was unable to find what.  None of the information that I could
find online that I could make sense of stated exactly which files or
settings the UEFI firmware first goes to.

One thing that seems to be the case but is not made clear is that grub
needs two partitions for booting.  One is a plain EFI partition and the
other is a normally formatted (e.g. ext4) partition mounted at /boot.
Confusingly, although the EFI partition seems to get mounted as
/boot/efi it has to be a separate partition in the installer
partitioning scheme.