View previous topic :: View next topic |
Author |
Message |
sublogic Apprentice
Joined: 21 Mar 2022 Posts: 283 Location: Pennsylvania, USA
|
Posted: Sun Nov 24, 2024 2:20 am Post subject: [Solved] My layout confuses grub |
|
|
Summary:
My new-to-me laptop arrived this week. Install time. I followed the amd64 handbook, deviating only to set up encrypted partitons for data protection at rest (best done at install time). Kernel is gentoo-kernel-bin, ugrd for the initramfs, grub for bootloader. The storage is gpt-partitioned like so: Code: |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /efi
└─nvme0n1p2 259:2 0 237.5G 0 part
└─cleartxt 253:0 0 237.5G 0 crypt
├─vg0-swap 253:1 0 32G 0 lvm [SWAP]
├─vg0-root 253:2 0 40G 0 lvm /
└─vg0-home 253:3 0 40G 0 lvm /home |
There isn't a separate boot partition, all the booting bits must go under /efi. Apparently when I emerged gentoo-kernel-bin,- emerge ran installkernel,
- installkernel copied the files to the right place, and
- installkernel ran ugrd, which generated a good initramfs, and
- installkernel ran grub-mkconfig, which found the kernel and initramfs, but
- grub-mkconfig created a bad grub.cfg .
Why ? Isn't this a supported layout ? What did I miss ?
============================================================================
Details:
Upon rebooting I got this: Code: | Booting `Gentoo GNU/Linux'
error: no such device: 70611462-a82b-4c7d-abe6-1b5a29b0a24f
Loading Linux 6.6.58-gentoo-dist ...
error: no server is specified
Loading initial ramdisk ...
error: you need to load the kernel first.
Press any key to continue...
Failed to boot both default and fallback entries.
Press any key to continue... | (Typed from a screenshot.)
Duckduckgo to the rescue: press "any key" as told, look around in the grub shell using "ls" and "set root". Code: | grub> ls
(hd0) (hd0,gpt2) (hd0,gpt1)
grub> set root=(hd0,gpt1)
grub> ls /
efi/
grub> ls /efi
gentoo/
grub> ls /efi/gentoo
amd-uc.img vmlinuz-6.6.58-gentoo-dist.efi initramfs-6.6.58-gentoo-dist.img System.map-6.6.58-gentoo-dist |
HAH ! It's obvious now. The /efi/EFI/gentoo/grub/grub.cfg is garbage.
Boot rescue media and replace it by this: Code: | set root=(hd0,gpt1)
menuentry 'Gentoo Linux 6.6.58' {
echo 'loading kernel...'
linux /efi/gentoo/vmlinuz-6.6.58-gentoo-dist.efi
echo 'loading initramfs...'
initrd /efi/gentoo/initramfs-6.6.58-gentoo-dist.img
}
menuentry 'UEFI firmware settings' {
fwsetup
} | And that worked. I'm typing this from the laptop in question. But it's a band-aid. I would like future kernel upgrades to automatially generate a proper grub.cfg like they should.
Here's the bad grub.cfg (wgetpaste) . And emerge --info (wgetpaste)
Deviations and choices from the handbook: Code: | ==> /etc/portage/package.use/installkernel <==
sys-kernel/installkernel grub ugrd
sys-kernel/gentoo-kernel -initramfs
sys-kernel/gentoo-kernel-bin -initramfs
==> /etc/kernel/install.conf <==
# This file is managed by sys-kernel/installkernel
layout=efistub
initrd_generator=ugrd
uki_generator=none |
Files after "emerge sys-kernel/gentoo-kernel-bin": Code: | ls -F /efi/EFI/gentoo
amd-uc.img* initramfs-6.6.58-gentoo-dist.img*
config-6.6.58-gentoo-dist* System.map-6.6.58-gentoo-dist*
grub/ vmlinuz-6.6.58-gentoo-dist.efi*
ls -F /efi/EFI/gentoo/grub
fonts/ grub.cfg* grubenv* locale/ themes/ x86_64-efi/ |
At Bootloader default: grub: Code: | # grub-install --efi-directory=/efi --boot-directory=/efi/EFI/gentoo | That must have worked, because there was a grubx64.efi* in /efi/EFI/gentoo and the UEFI firmware went straight to grub. The only thing messed up was the grub.cfg .
So, what step did I skip that confused grub-mkconfig ?
Or is my setup not directly supported by grub-mkconfig ?
Last edited by sublogic on Mon Nov 25, 2024 7:37 pm; edited 1 time in total |
|
Back to top |
|
|
jburns Veteran
Joined: 18 Jan 2007 Posts: 1220 Location: Massachusetts USA
|
Posted: Sun Nov 24, 2024 4:16 am Post subject: |
|
|
Did you mount the /efi partition? |
|
Back to top |
|
|
sMueggli Guru
Joined: 03 Sep 2022 Posts: 514
|
Posted: Sun Nov 24, 2024 9:12 am Post subject: |
|
|
The first decision you have to make: Do you want an encrypted /boot or not? It looks like you do not want an encrypted /boot because you are copying everything to the unencrypted /efi mountpoint.
In case of an unencrypted /boot you have to ask yourself, whether you want to abuse the ESP as /boot or have separate partitions for /efi and /boot.
After you have a clear idea of how you want to setup the system, you can execute "grub-install" and "grub-mkconfig" and should have a valid grub.cfg. |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3779 Location: Rasi, Finland
|
Posted: Sun Nov 24, 2024 9:52 am Post subject: |
|
|
sMueggli wrote: | The first decision you have to make: Do you want an encrypted /boot or not? It looks like you do not want an encrypted /boot because you are copying everything to the unencrypted /efi mountpoint. | Yes. I think that's the intention of the OP. sublogic wrote: | Code: |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /efi
└─nvme0n1p2 259:2 0 237.5G 0 part
└─cleartxt 253:0 0 237.5G 0 crypt
├─vg0-swap 253:1 0 32G 0 lvm [SWAP]
├─vg0-root 253:2 0 40G 0 lvm /
└─vg0-home 253:3 0 40G 0 lvm /home |
There isn't a separate boot partition, all the booting bits must go under /efi. |
As for mounting the /efi, I think kernel ebuilds do not mount /efi automatically, so you have to do that manually, or by writing a pre_pkg_preinst() function to /etc/portage/env/sys-kernel/gentoo-kernel/my_automount_efi.sh for example. I think there are alternative (better) ways to accomplish the automounting... _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
Nowa Developer
Joined: 25 Jun 2014 Posts: 463 Location: Nijmegen
|
Posted: Sun Nov 24, 2024 12:54 pm Post subject: |
|
|
GRUB (specifically grub-mkconfig) does not support the efistub layout, only the grub layout. If you want your kernels on the ESP and use GRUB at the same time, then the solution is to mount the ESP at /boot. _________________ OS: Gentoo 6.10.12-gentoo-dist, ~amd64, 23.0/desktop/plasma/systemd
MB: MSI Z370-A PRO
CPU: Intel Core i9-9900KS
GPU: Intel Arc A770 16GB & Intel UHD Graphics 630
SSD: Samsung 970 EVO Plus 2 TB
RAM: Crucial Ballistix 32GB DDR4-2400 |
|
Back to top |
|
|
sublogic Apprentice
Joined: 21 Mar 2022 Posts: 283 Location: Pennsylvania, USA
|
Posted: Mon Nov 25, 2024 2:05 am Post subject: |
|
|
@jburns,zucca: /efi was mounted.
Nowa wrote: | GRUB (specifically grub-mkconfig) does not support the efistub layout, only the grub layout. | I see. Okay, one solution: partition surgery.- Back up /efi;
- Split the EFI partition in two. Old partion 1 becomes partitions 1 and 2, old partition 2 becomes partition 3 otherwise untouched.
- mkfs.vfat on part.1, mount on /efi, mkfs.ext4 on part.2, mount on /boot.
- /etc/kernel/install.conf: layout=grub
- emerge --config gentoo-kernel-bin
- grub-install --efi-directory=/efi --boot-directory=/boot
It might even be doable live, without rebooting. (Of course I have to reboot to test it.) I'll practice re-partitioning on a loop device first.
Nowa wrote: | If you want your kernels on the ESP and use GRUB at the same time, then the solution is to mount the ESP at /boot. | Hm, will that work ? I guess I can try.
Uh, also I won't do anything until I have borgbackup set up and I have backups of everything. And verified the backups from rescue media. (Sysrescue has borg, yea !)
I'll keep you posted.
EDIT: it's "gentoo-kernel-bin", not "gentoo-kernel-dist".
Last edited by sublogic on Mon Nov 25, 2024 7:23 pm; edited 1 time in total |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3779 Location: Rasi, Finland
|
Posted: Mon Nov 25, 2024 8:18 am Post subject: |
|
|
sublogic wrote: | Okay, one solution: partition surgery. | I have only /boot, that's also my EFI partition. But I use refind, not grub.
So you could possibly just chance the mount point from /efi to /boot.
Although your way of having separate /efi and /boot should be more sure shot way, as it's the new recommended way. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
sublogic Apprentice
Joined: 21 Mar 2022 Posts: 283 Location: Pennsylvania, USA
|
Posted: Mon Nov 25, 2024 7:37 pm Post subject: |
|
|
It worked like a charm ! fdisk from the live system. I didn't need my backups. New layout: Code: | # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 256M 0 part /efi
├─nvme0n1p2 259:2 0 237.5G 0 part
│ └─cleartxt 253:0 0 237.5G 0 crypt
│ ├─vg0-swap 253:1 0 32G 0 lvm [SWAP]
│ ├─vg0-root 253:2 0 40G 0 lvm /
│ └─vg0-home 253:3 0 40G 0 lvm /home
└─nvme0n1p3 259:3 0 768M 0 part /boot
df -h /boot /efi
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p3 739M 47M 638M 7% /boot
/dev/nvme0n1p1 253M 142K 252M 1% /efi |
Partitions 1 and 3 are contiguous on the disk (as much as that makes sense for an NVME). Partition 2 was never touched. Code: | Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 526335 524288 256M EFI System
/dev/nvme0n1p2 2099200 500117503 498018304 237.5G Linux LVM
/dev/nvme0n1p3 526336 2099199 1572864 768M Linux filesystem |
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|