Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
My layout confuses grub
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
sublogic
Apprentice
Apprentice


Joined: 21 Mar 2022
Posts: 274
Location: Pennsylvania, USA

PostPosted: Sun Nov 24, 2024 2:20 am    Post subject: My layout confuses grub Reply with quote

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:
  • At Partitioning the disk with GPT for UEFI the storage was set up as above.
  • At sys-kernel/installkernel and initramfs:
    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 ?
Back to top
View user's profile Send private message
jburns
Veteran
Veteran


Joined: 18 Jan 2007
Posts: 1220
Location: Massachusetts USA

PostPosted: Sun Nov 24, 2024 4:16 am    Post subject: Reply with quote

Did you mount the /efi partition?
Back to top
View user's profile Send private message
sMueggli
Guru
Guru


Joined: 03 Sep 2022
Posts: 500

PostPosted: Sun Nov 24, 2024 9:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3732
Location: Rasi, Finland

PostPosted: Sun Nov 24, 2024 9:52 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
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