Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] Switch from MBR/genkernel to EFI, boot failure
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
bookwood
Tux's lil' helper
Tux's lil' helper


Joined: 06 Oct 2005
Posts: 133
Location: Dortmund

PostPosted: Sun May 11, 2025 7:55 am    Post subject: [solved] Switch from MBR/genkernel to EFI, boot failure Reply with quote

Last week my laptop broke and I bought a Thinkpad P15. The P15 can no longer boot the old MBR partition; it only supports EFI. I discovered that genkernel is now obsolete. The manual describes several methods for installing the kernel, but which is the easiest way to get my new notebook to boot from the rescue system?


    There is no manual to replace genkernel
    The installation manual, now, offers many solutions to install the kernel
    There is now a gentoo-kernel package.


Here is a dump of my old partition table:
Code:

label: dos
label-id: 0x36a419d6
device: /dev/nvme0n1
unit: sectors
sector-size: 512

/dev/nvme0n1p1 : start=        2048, size=        4096, type=83
/dev/nvme0n1p2 : start=        6144, size=      385024, type=83
/dev/nvme0n1p3 : start=      391168, size=  3906637824, type=83


The third partition was encrypted with openLuks.

I converted it to gpt partition, deleted the first two partition, renumbered the crypted to 2, added a new efi partition in place of the old boot and mbr partition and mounted the partition to /efi. I left the old /boot mount point empty:
Code:
label: gpt
label-id: BDB74C55-F57D-4B62-AC6E-F2BB23CA035C
device: /dev/nvme0n1
unit: sectors
first-lba: 34
last-lba: 3907029134
sector-size: 512

/dev/nvme0n1p1 : start=        2048, size=      389120, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=6F60A962-8FFB-4561-89F8-7E500F831259
/dev/nvme0n1p2 : start=      391168, size=  3906637824, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=AADC5105-0C92-DF47-AC3D-8E215FBB8C24



After rebuild the kernel and modules with
Code:
make && make modules_install && make install

I reinstalled grub to efi and setted up crypto in grub config. The system boot now, shows me up a luks password promp, but after entering the correct password, it shows up a grub rescue prompt and stops.

I followed the grub section in the installation manual, setted the efistub use flag and so on.
I think that the kernel is not installed from the /boot folder to the mounted /efi forder.

Help welcome :-)


Last edited by bookwood on Thu May 15, 2025 10:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
bstaletic
Guru
Guru


Joined: 05 Apr 2014
Posts: 517

PostPosted: Sun May 11, 2025 9:11 am    Post subject: Reply with quote

make install executes installkernel if available.
Do you have installkernel and if so, is it gentoo's sys-kernel/installkernel and if so, what USE flag have you set?
Back to top
View user's profile Send private message
bookwood
Tux's lil' helper
Tux's lil' helper


Joined: 06 Oct 2005
Posts: 133
Location: Dortmund

PostPosted: Sun May 11, 2025 11:01 am    Post subject: Reply with quote

My emerge --info
https://bpa.st/7HAQ

And installkernel:
Code:

livecd /usr/src/linux # LANG=C eix -s installkernel
[I] sys-kernel/installkernel
     Available versions:  50 (~)55 (~)56 (~)57 (~)59 {dracut efistub grub refind systemd systemd-boot ugrd uki ukify}
     Installed versions:  59(15:06:16 05/10/25)(dracut efistub grub systemd -refind -systemd-boot -ugrd -uki -ukify)
     Homepage:            https://github.com/projg2/installkernel-gentoo https://wiki.gentoo.org/wiki/Installkernel
     Description:         Gentoo fork of installkernel script from debianutils
Back to top
View user's profile Send private message
bstaletic
Guru
Guru


Joined: 05 Apr 2014
Posts: 517

PostPosted: Sun May 11, 2025 11:25 am    Post subject: Reply with quote

If you're using grub, you don't want USE=efistub for sys-kernel/installkernel.
I don't know if that's your issue, but it could be. Especially considering that USE flag is described as experimental.
equery u installkernel:
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for sys-kernel/installkernel-59:
 U I
 - - dracut       : Generate an initramfs or UKI on each kernel installation
 - - efistub      : EXPERIMENTAL: Update UEFI configuration on each kernel installation
 + + grub         : Re-generate grub.cfg on each kernel installation, used grub.cfg is overridable with GRUB_CFG env var
 - - refind       : Install a Gentoo icon for rEFInd alongside the (unified) kernel image, used icon is overridable with REFIND_ICON env var
 - - systemd      : Use systemd's kernel-install to install kernels, overridable with SYSTEMD_KERNEL_INSTALL env var
 - - systemd-boot : Use systemd-boot's native layout by default
 - - ugrd         : Generate an initramfs using UGRD on each kernel installation
 - - uki          : Install UKIs to ESP/EFI/Linux for EFI stub booting and/or bootloaders with support for auto-discovering UKIs
 - - ukify        : Build an UKI with systemd's ukify on each kernel installation
Back to top
View user's profile Send private message
bookwood
Tux's lil' helper
Tux's lil' helper


Joined: 06 Oct 2005
Posts: 133
Location: Dortmund

PostPosted: Sun May 11, 2025 11:52 am    Post subject: Reply with quote

It seems to install the kernel in /efs, but my efs partition is to small.
Code:

Command (m for help): p

Disk /dev/nvme0n1: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: CT2000P5PSSD8
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: BDB74C55-F57D-4B62-AC6E-F2BB23CA035C

Device          Start        End    Sectors  Size Type
/dev/nvme0n1p1   2048     391167     389120  190M EFI System
/dev/nvme0n1p2 391168 3907028991 3906637824  1.8T Linux filesystem

On my old mbr solutions, the partition for the kernel was big enough. I need to backup my crypted partition. I will Post my solutions after the Backup.


Last edited by bookwood on Sun May 11, 2025 12:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1681
Location: Richmond Hill, Canada

PostPosted: Sun May 11, 2025 12:18 pm    Post subject: Reply with quote

bookwood,

Not sure if you still need more help. But if you do can you confirm which grub-prompt you got? "grub> " or "grub rescue> ". (I know you stated "it shows up a grub rescue prompt and stops", but just want to be sure)

If your intent is to use GRUB for all future boot process then the EFI setting is less relevant in kernel or in system. Since you were able to get the EFI boot service start GRUB already. Just fix grub boot configuration is good enough.
Back to top
View user's profile Send private message
bookwood
Tux's lil' helper
Tux's lil' helper


Joined: 06 Oct 2005
Posts: 133
Location: Dortmund

PostPosted: Wed May 14, 2025 7:38 am    Post subject: Reply with quote

I resized my partitions, and the filesystem full error is gone:
Code:

livecd ~ # parted /dev/nvme0n1
GNU Parted 3.5
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: CT2000P5PSSD8 (nvme)
Disk /dev/nvme0n1: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  1276MB  1275MB  fat32              boot, esp
 2      1276MB  2000GB  1999GB

(parted)


I installed grub:
Code:

livecd / # grep ^[^#] /etc/default/grub
GRUB_DISTRIBUTOR="Gentoo"
GRUB_GFXMODE=1920x1080
GRUB_DISABLE_LINUX_PARTUUID=false
GRUB_ENABLE_CRYPTODISK=y
GRUB_PRELOAD_MODULES="lvm"
RUB_CMDLINE_LINUX="dolvm udev doscsi crypt_root=UUID=af7a8c2b-8a5e-4d68-xxxx-xxxxxxxxx root=/dev/mapper/root resume=/dev/mapper/hal9000-swap transparent_hugepage=always real_root=/dev/mapper/hal9000-root init=/usr/lib/systemd/systemd "
livecd / #
livecd / # LANG=C grub-install  --target=x86_64-efi  --efi-directory=/efi  --removable
Installing for x86_64-efi platform.
Installation finished. No error reported.

I have no longer a /boot, the first partition is mounted as /efi. I installed the gentoo-kernel and gentoo-sources. Genkernel is obsolete so I compile the kernel:
Code:

ivecd / #
livecd / # cd /usr/src/linux
livecd /usr/src/linux # make -j 20 && make -j 20 modules_install && make install
  .
  .
  .
livecd /usr/src/linux # make install
  INSTALL /boot 《------- is this ok? I have no /boot anymore
dracut[I]: Executing: /usr/bin/dracut -f --add-confdir hostonly --kernel-image /usr/src/linux/arch/x86/boot/bzImage --no-uefi --kver 6.12.21-gentoo-x86_64 /tmp/kernel-install.staging.TX7hpo/initrd
dracut[I]: *** Including module: bash ***
dracut[I]: *** Including module: systemd ***
dracut[I]: *** Including module: systemd-ask-password ***
dracut[I]: *** Including module: systemd-battery-check ***
dracut[I]: *** Including module: systemd-cryptsetup ***
dracut[I]: *** Including module: systemd-initrd ***
dracut[I]: *** Including module: systemd-journald ***
dracut[I]: *** Including module: systemd-modules-load ***
dracut[I]: *** Including module: systemd-sysctl ***
dracut[I]: *** Including module: systemd-tmpfiles ***
dracut[I]: *** Including module: systemd-udevd ***
dracut[I]: *** Including module: i18n ***
dracut[I]: *** Including module: systemd-sysusers ***
Creating group 'systemd-journal' with GID 190.
dracut[I]: *** Including module: crypt ***
dracut[I]: *** Including module: dm ***
dracut[I]: *** Including module: kernel-modules ***
dracut[I]: *** Including module: kernel-modules-extra ***
dracut[I]: *** Including module: lvm ***
dracut[I]: *** Including module: crypt-gpg ***
dracut[I]: *** Including module: rootfs-block ***
dracut[I]: *** Including module: terminfo ***
dracut[I]: *** Including module: udev-rules ***
dracut[I]: *** Including module: dracut-systemd ***
dracut[I]: *** Including module: usrmount ***
dracut[I]: *** Including module: base ***
dracut[I]: *** Including module: fs-lib ***
dracut[I]: *** Including module: shell-interpreter ***
dracut[I]: *** Including module: shutdown ***
dracut[I]: *** Including modules done ***
dracut[I]: *** Installing kernel module dependencies ***
dracut[I]: *** Installing kernel module dependencies done ***
dracut[I]: *** Resolving executable dependencies ***
dracut[I]: *** Resolving executable dependencies done ***
dracut[I]: *** Hardlinking files ***
dracut[I]: *** Hardlinking files done ***
dracut[I]: *** Generating early-microcode cpio image ***
dracut[I]: *** Store current command line parameters ***
dracut[I]: Stored kernel commandline:
dracut[I]:  dolvm udev doscsi crypt_root=UUID=af7a8c2b-8a5e-4d68-xxxx-xxxxxxxxx root=/dev/mapper/root resume=/dev/mapper/hal9000-swap transparent_hugepage=always real_root=/dev/mapper/hal9000-root init=/usr/lib/systemd/systemd
dracut[I]:  rd.luks.uuid=luks-af7a8c2b-8a5e-4d68-xxxx-xxxxxxxxxxxx
dracut[I]:  rd.lvm.lv=hal9000/usr   rd.lvm.lv=hal9000/root
dracut[I]:  root=/dev/mapper/hal9000-root rootfstype=xfs rootflags=rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquotadracut[I]: *** Stripping files ***
dracut[I]: *** Stripping files done ***
dracut[I]: *** Creating image file '/tmp/kernel-install.staging.TX7hpo/initrd' ***
dracut[I]: Using auto-determined compression method 'zstd'
dracut[I]: *** Creating initramfs image file '/tmp/kernel-install.staging.TX7hpo/initrd' done ***
livecd /usr/src/linux #
livecd /usr/src/linux #
livecd /usr/src/linux # blkid /dev/nvme0n1p2
/dev/nvme0n1p2: UUID="af7a8c2b-8a5e-4d68-xxxx-xxxxxxxxxxc" TYPE="crypto_LUKS" PARTUUID="18388cd7-c184-d24a-xxxx-xxxxxxxxxxcc"
livecd /usr/src/linux #
ivecd /usr/src/linux # kernel-install list
VERSION               HAS KERNEL PATH
6.12.21-gentoo-x86_64          ✗ /usr/lib/modules/6.12.21-gentoo-x86_64
6.12.25-gentoo-dist            ✓ /usr/lib/modules/6.12.25-gentoo-dist
livecd /usr/src/linux # eix -s installkernel
[I] sys-kernel/installkernel
     Available versions:  50 (~)55 (~)56 (~)57 (~)59 {dracut efistub grub refind systemd systemd-boot ugrd uki ukify}
     Installed versions:  59(00:21:49 05/14/25)(dracut efistub grub systemd -refind -systemd-boot -ugrd -uki -ukify)
     Homepage:            https://github.com/projg2/installkernel-gentoo https://wiki.gentoo.org/wiki/Installkernel
     Description:         Gentoo fork of installkernel script from debianutils

livecd /usr/src/linux #
livecd /usr/src/linux # grub-mkconfig -o /boot/grub/grub.cfg                                        Generating grub configuration file ...
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
livecd /usr/src/linux #

The dist kernel seems ok, but the compiled kernel not (kernel-install list output above). Here is the contence of my efi:
Code:
livecd /usr/src/linux # find /efi
/efi
/efi/EFI
/efi/EFI/gentoo
/efi/EFI/gentoo/grubx64.efi
/efi/EFI/gentoo/kernel-6.12.21-gentoo-x86_64.efi
/efi/EFI/gentoo/initramfs-6.12.21-gentoo-x86_64.img
/efi/EFI/gentoo/kernel-6.12.25-gentoo-dist.efi
/efi/EFI/gentoo/initramfs-6.12.25-gentoo-dist.img
/efi/EFI/BOOT
/efi/EFI/BOOT/BOOTX64.EFI
livecd /usr/src/linux #

I try to reboot with no luck. No grub menu, only a password promt, after entering my luks password to decrypt my disk, the bbot stops with a grub rescue prompt:
Code:
Enter passphrase for hd0,gpt2 (af7a8c2b-8a5e-4d68-xxxx-xxxxxxxxxx):
error: Invalid passphrase.
error: disk "lvmid/QaUxxxxxxxxxxxxxxxx" not found.
Entering rescue mode...
grub rescue>

I do not understand what shoud the system want to do with the /boot partition, I have now a /efi partition. I found nothing about this question. Is my way correct or shoul I use systemd?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23516

PostPosted: Wed May 14, 2025 12:35 pm    Post subject: Reply with quote

You are not required to use systemd to make a system boot, even on EFI.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1681
Location: Richmond Hill, Canada

PostPosted: Wed May 14, 2025 12:52 pm    Post subject: Reply with quote

bookwood wrote:
I try to reboot with no luck. No grub menu, only a password promt, after entering my luks password to decrypt my disk, the bbot stops with a grub rescue prompt:
Code:
Enter passphrase for hd0,gpt2 (af7a8c2b-8a5e-4d68-xxxx-xxxxxxxxxx):
error: Invalid passphrase.
error: disk "lvmid/QaUxxxxxxxxxxxxxxxx" not found.
Entering rescue mode...
grub rescue>

I do not understand what shoud the system want to do with the /boot partition, I have now a /efi partition. I found nothing about this question. Is my way correct or shoul I use systemd?
The messages seems indicate wrong password/passphrase. So that could be one of the problem.

In the case of getting "grub rescue> " mean most likely that grub was not able to access its modules therefor drop to buildin minicmd. In your case it make sense because grub likely installed in wrong place, possible when you execute grub-install the /efi was not mounted.

Conceptually /boot does not need to be on its own partition. It can be stay on rootfs as long as boot loader (in your case grub) have access to rootfs.

Since grub apparently not able access nvme0np1 (the /efi content) so this is the first problem need to solve in order to move on.
Back to top
View user's profile Send private message
bookwood
Tux's lil' helper
Tux's lil' helper


Joined: 06 Oct 2005
Posts: 133
Location: Dortmund

PostPosted: Thu May 15, 2025 10:38 pm    Post subject: Reply with quote

First, the P15 Thinkpad boot now. I got it with grub and dracut 8)

I decided to recreate a /boot partition, and my system was able to boot:

Code:
GNU Parted 3.6
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                               
Model: CT2000P5PSSD8 (nvme)
Disk /dev/nvme0n1: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  840MB   839MB   fat32              boot, esp
 2      840MB   1276MB  436MB   ext2
 3      1276MB  2000GB  1999GB


The size of the /efi and /boot partitions will be corrected in future.
Code:
 ~ # df -h /efi /boot
Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
/dev/nvme0n1p1  799M    304K  799M    1% /efi
/dev/nvme0n1p2  390M     99M  271M   27% /boot


One important point was the deprecated genkernel kernel parameter crypt_root, it needed to changed to the new dracut labels. The crypt_root parameter changed to rd.luks.uuid. The parameters can be determined by the following command:
Code:
~ # dracut --print-cmdline
 rd.luks.uuid=luks-af7a8c2b-8a5e-4d68-xxxx-xxxxxxxxx rd.lvm.lv=hal9000/root   rd.lvm.lv=hal9000/usr   rd.lvm.lv=hal9000/swap   resume=/dev/mapper/hal9000-swap root=/dev/mapper/hal9000-root rootfstype=xfs rootflags=rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota


now the changes to the config files:
Code:
~ # grep ^[^#] /etc/default/grub
GRUB_DISTRIBUTOR="Gentoo"
GRUB_GFXMODE=1920x1080
GRUB_DISABLE_LINUX_PARTUUID=false
GRUB_ENABLE_CRYPTODISK=y
GRUB_PRELOAD_MODULES="lvm"
GRUB_CMDLINE_LINUX="dolvm udev doscsi rd.luks.uuid=luks-af7a8c2b-8a5e-4d68-b4b0-f2692e094c97 rd.lvm.lv=hal9000/usr   rd.lvm.lv=hal9000/root   root=/dev/mapper/hal9000-root rootfstype=xfs resume=/dev/mapper/hal9000-swap transparent_hugepage=always init=/usr/lib/systemd/systemd "
grep ^[^#] /etc/dracut.conf
add_dracutmodules+=" crypt crypt-gpg dm rootfs-block "
kernel_cmdline+=" dolvm udev doscsi crypt_root=UUID=af7a8c2b-8a5e-4d68-b4b0-f2692e094c97 root=/dev/mapper/root resume=/dev/mapper/hal9000-swap transparent_hugepage=always real_root=/dev/mapper/hal9000-root init=/usr/lib/systemd/systemd "


I follow your suggestions an disabled the efistub useflag
Code:
[I] sys-kernel/installkernel
     Verfügbare Versionen:   50 ~59-r1 {dracut efistub grub refind systemd systemd-boot ugrd uki ukify}
     Installierte Versionen: 50(21:59:01 14.05.2025)(dracut grub systemd -efistub -refind -systemd-boot -ugrd -uki -ukify)
[I] sys-boot/grub
     Verfügbare Versionen:   (2) 2.12-r6(2/2.12-r6)^tu **9999(2/9999)*l^tu
       {+device-mapper doc efiemu +fonts libzfs mount nls sdl secureboot test +themes truetype verify-sig GRUB_PLATFORMS="coreboot efi-32 efi-64 emu ieee1275 loongson multiboot pc qemu qemu-mips uboot xen xen-32 xen-pvh"}
     Installierte Versionen: 2.12-r6(2/2.12-r6)^t(07:43:16 14.05.2025)(device-mapper fonts nls sdl themes truetype -doc -efiemu -libzfs -mount -secureboot -test -verify-sig GRUB_PLATFORMS="efi-64 -coreboot -efi-32 -emu -ieee1275 -loongson -multiboot -pc -qemu -qemu-mips -uboot -xen -xen-32 -xen-pvh")
[I] sys-kernel/dracut
     Verfügbare Versionen:   060_pre20240104-r4^t 103-r4^t 106-r2^t **9999*l^t {debug +dracut-cpio selinux test}
     Installierte Versionen: 106-r2^t(00:39:36 14.05.2025)(dracut-cpio -debug -selinux -test)


After repartitioning I executed following steps:
Code:
grub-install --target=x86_64-efi --efi-directory=/efi
cd /usr/src/linux; make -j 20 && make -j 20 modules_install && make install
grub-mkconfig -o /boot/grub/grub.cfg


The screen show now the grub boot menu, after a short time I would asked for the encription password and the system boots.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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