Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Making old SSD bootable with EFI
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Thu Dec 07, 2023 5:09 am    Post subject: Making old SSD bootable with EFI Reply with quote

I had an Atom computer that went down, motherboard or power supply, I don't know.
That atom had an SSD drive.  
I put together a new Intel i5 with nvme drive but I transferred the SSD to the new box as well.
The Intel i5-12400 has an integrated graphic card and to run the bootable drive needs to be an EFI System.
Installing Gentoo on Nvme-drive on this system was relatively easy.  But I can not make the SSD drive that I transferred from the Atom PC bootable on the Intel box.
The problem is the old SSD hasn't been upgraded in several years, it is running portage-2.3.24-r1
and kernel linux-4.9.6-gentoo-r1.  
The system I think is too old for an upgrade.
I bootstrap the system and try to convert the boot partition to EFI  but can not.

It is running grub-0.97-r18 (without GRUB_PLATFORMS="efi-64")
tried to compile it but getting an error message:
Code:
livecd / # emerge -avq sys-boot/grub
 
!!! All ebuilds that could satisfy "sys-boot/grub" have been masked.
!!! One of the following masked packages is required to complete your request:
- sys-boot/grub-9999::gentoo (masked by: EAPI 7)
- sys-boot/grub-2.12_rc1-r1::gentoo (masked by: EAPI 7)
- sys-boot/grub-2.06-r9::gentoo (masked by: EAPI 7)
- sys-boot/grub-2.06-r8::gentoo (masked by: EAPI 7)

The current version of portage supports EAPI '6'. You must upgrade to a
newer version of portage before EAPI masked packages can be installed.


The old SSD had a bootable partition /dev/sda1 ext2 which I mounted on nvme-disk and made an old kernel backup to /boot_backup on the same SSD drive.
- I deleted the /dev/sda1 partition and created new partition EFI System and format it as vfat:
mkfs.fat -F 32 /dev/sda1
- mounted the new sda1 partition under /atom/efi (root partition /dev/sda3 is mounted in dir: /atom)
- run:
Code:
grub-install --target=x86_64-efi --efi-directory=/atom/efi

- copied to SSD /boot dir. all the old kernel files (I backup previously):
    System.map-current
    config-current
    kernel-current

run:
Code:
grub-mkconfig -o /atom/boot/grub/grub.cfg

The old /boot/grub had old file: grub.conf with entries:
Quote:
root (hd0,0)
kernel /boot/kernel-current root=/dev/sda3 vga=normal

so the above command generated new file: grub.cfg with new entries and took my kernel files from nvme-disk:  vmlinuz-6.1.57-gentoo
'Gentoo GNU/Linux, with Linux 6.1.57-gentoo'  not my old kerenel files from "/atom/boot"

In /efi/EFI/genoo directory there is binary file:
-rwxr-xr-x 1 root root 135168 Dec  6 13:38 grubx64.efi

Does this file  grubx64.efi point to the boot directory and configuration file: grub.cfg ?

I have noticed grub-install has some options like:  --boot-directory=DIR
would it help somehow to point to /atom/boot directory so it can use:
"kernel-current" instead of "vmlinuz-6.1.57-gentoo"
example:
Code:
grub-install --target=x86_64-efi --efi-directory=/atom/efi --boot-directory=/atom/boot

Or is it possible to edit manually grub.cfg even though it says # DO NOT EDIT THIS FILE

2.) Another solution is I could bootstrap the old SSD /dev/sda and try to try to install with grub
but that grub is and old version 0.97-something and is not compiled with "GRUB_PLATFORMS="efi-64"

3.) I tried manually, edit the /boot/grub/grub.cfg despite the fact that it says: DO NOT EDIT THIS FILEBios list this SSD as bootable and boot menu show correct kernel from old SSD named "kernel-current"  but nothing is booting, the cursor just sit on next line. Could it be the kernel configuration?  This disk was booting OK on old Atom box so why wont it boot on new Intel i5
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4236
Location: Bavaria

PostPosted: Thu Dec 07, 2023 1:10 pm    Post subject: Reply with quote

Joseph_sys,

you have done more than necessary ... you only need a single ESPartition and ONE grub. You already had that on your NVMe installation. The only thing missing was a boot entry for your old kernel on the SSD.

Yes, you should not edit the /boot/grub/grub.cfg directly ... because ... it will be overwritten by grub-mkconfig every time you use it ... and you don't want to adjust this cfg every time. (you need the grub-mkconfig every time you have installed a new kernel and want to integrate it back into the grub menu).

There are two ways to create an additional grub menu entry for a different operating system:

1. the use of os-prober, or

2. manually creating an additional entry via the configuration files in /etc/grub.d. This is described here:
https://wiki.gentoo.org/wiki/GRUB#Manipulating_configuration_scripts

Now you have made a small mess by creating a second ESP on the ssd and installing a second grub there. But that shouldn't be a problem ... you just don't need to use it ... by using "efibootmgr" to check which UEFI entries you have. You should now have two: one pointing to the grub of the SSD, and a second pointing to the grub of the NVMe. Because you can no longer update your old system, but you certainly want to update your system on the NVMe, you should use the grub of the NVMe. Try the following:

Boot into your gentoo of the NVMe and change the partition type of the ESP on the SSD back to Linux (=no ESP boot flag anymore). Boot through and check if your UEFI now only shows the grub of the NVMe. Start your Gentoo on the NVMe again.

I cannot suggest the use of os-prober (and maybe it will not find your old kernel) - so my suggestion is to go with (2) and create a /etc/grub.d/40_custom. You can use the settings from /boot/grub/grub.cfg as HELP. After a grub-mkconfig you should check the /boot/grub/grub.cfg again (you must give your old kernel the correct root= parameter).
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1548
Location: South America

PostPosted: Thu Dec 07, 2023 4:02 pm    Post subject: Re: Making old SSD bootable with EFI Reply with quote

I'd like to highlight a couple of things:

Joseph_sys wrote:
The problem is the old SSD hasn't been upgraded in several years, it is running portage-2.3.24-r1
and kernel linux-4.9.6-gentoo-r1.  
The system I think is too old for an upgrade.

May I ask what do you want to do with the Atom computer's SSD? Just access data, or actually use the old, unupgradable Gentoo system installed on it? If it's the former, can't you just boot, use and maintain the up to date Gentoo on the NVMe drive, and mount the SSD's filesystems e. g. somewhere in /media?

Joseph_sys wrote:
3.) I tried manually, edit the /boot/grub/grub.cfg despite the fact that it says: DO NOT EDIT THIS FILEBios list this SSD as bootable and boot menu show correct kernel from old SSD named "kernel-current"  but nothing is booting, the cursor just sit on next line. Could it be the kernel configuration?  This disk was booting OK on old Atom box so why wont it boot on new Intel i5

Was the kernel on the SSD custom-configured for that particular Atom computer? If so, then yes, it might be unsuitable for the i5 one...
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Thu Dec 07, 2023 6:11 pm    Post subject: Reply with quote

Thank you pietinger and GDH-gentoo for the input.
Let me explain...:

pietinger wrote:
[snip...]
Yes, you should not edit the /boot/grub/grub.cfg directly ... because ... it will be overwritten by grub-mkconfig every time you use it ... and you don't want to adjust this cfg every time. (you need the grub-mkconfig every time you have installed a new kernel and want to integrate it back into the grub menu).

I created a backup copy of the /boot/grub/grub.cfg (in old SSD drive) besides I can always recreate that file "grub.cfg" with:
Code:
grub-mkconfig -o /atom/boot/grub/grub.cfg
but that doesn't help me as it takes kernel from nvme-drive and puts it in SSD drive, that is not what I need, it does not help me booting SSD-drive.
Originally, my Idea was to make the SSD-bootable and switch booting in Bios, but I suppose there is easier way of doing it, like you suggested below:
pietinger wrote:
There are two ways to create an additional grub menu entry for a different operating system:

1. the use of os-prober, or

2. manually creating an additional entry via the configuration files in /etc/grub.d. This is described here:
https://wiki.gentoo.org/wiki/GRUB#Manipulating_configuration_scripts

I've never use "os-proper" but it looks interesting and more suitable for me, I'll explain below...
pietinger wrote:
Now you have made a small mess by creating a second ESP on the ssd and installing a second grub there. But that shouldn't be a problem ... you just don't need to use it ... by using "efibootmgr" to check which UEFI entries you have. You should now have two: one pointing to the grub of the SSD, and a second pointing to the grub of the NVMe. Because you can no longer update your old system, but you certainly want to update your system on the NVMe, you should use the grub of the NVMe. Try the following:

Boot into your gentoo of the NVMe and change the partition type of the ESP on the SSD back to Linux (=no ESP boot flag anymore). Boot through and check if your UEFI now only shows the grub of the NVMe. Start your Gentoo on the NVMe again.


I can always delete the bootable partition on SSD, to make it less complicated and dual booting from new NVMe-drive.

pietinger wrote:
I cannot suggest the use of os-prober (and maybe it will not find your old kernel) - so my suggestion is to go with (2) and create a /etc/grub.d/40_custom. You can use the settings from /boot/grub/grub.cfg as HELP. After a grub-mkconfig you should check the /boot/grub/grub.cfg again (you must give your old kernel the correct root= parameter).

I'll try your suggestion hopefully something will work.
GDH-gentoo wrote:
May I ask what do you want to do with the Atom computer's SSD? Just access data, or actually use the old, unupgradable Gentoo system installed on it? If it's the former, can't you just boot, use and maintain the up to date Gentoo on the NVMe drive, and mount the SSD's filesystems e. g. somewhere in /media?

Here is an explanation what the Atom computer did:
This Atom PC run 24/7 and runs:

1.) Asterisk-11-something, I don't like to upgrade Asterisk as new versions tend to break something, so my motto was "if it ain't broken don't touch it." But hopefully I can upgrade to current Asterisk-16.30-something, apparently they are compatible Asterisk-11-something and Asterisk-16.30-something, but I have to test it.
And after it will run without a problems for a while I can scrap/upgrade gentoo on the SSD-disk.

2.) It runs Hylafax, but hylafax is not complicated and can easily be installed, just few configuration files.

So I like the idea of dual-booting, advantages:
- same IP-address, so the external audiocodes-units that register to Asterisk should work regardless as they register to same IP-address
- will have an extra backup.

I just have to figure it out as, I never configured dual booting before.

GDH-gentoo wrote:
Was the kernel on the SSD custom-configured for that particular Atom computer? If so, then yes, it might be unsuitable for the i5 one...


The kernel on SSD-drive was edited just to run the system, but I did not do any customization, in my opinion it should run in i5-Intel,
busides I can still boot strap SSD and make an adjustment but for some reason it doesn't boot at all. I can post kernel .config file; but it could be something with "grub.cfg" I modified manually on SSD disk; all I did was change some names and change drive UUID= and PARTUUID= of the corresponding entries.
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4236
Location: Bavaria

PostPosted: Thu Dec 07, 2023 7:02 pm    Post subject: Reply with quote

Joseph_sys wrote:
The kernel on SSD-drive was edited just to run the system, but I did not do any customization, in my opinion it should run in i5-Intel,

What GDH-gentoo has meant is: With Gentoo you can compile all applications for a specific CPU - e.g. if you have in your make.conf:
Code:
COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
...

Now you want run applications which have been compiled for the instruction set of an ATOM CPU ... yes, both CPUs are Intel CPUs ... yes, it could be that the machine language an old ATOM understands will be understand also from a newer i5 ... but it could be possible that the ATOM has some instructions an i5 dont understand ... then every applications which uses this instruction(s) (=have been compiled using these) will give you a "illegal instruction" in your dmesg and will break (sorry, I am not a CPU expert knowing the instructions set of an ATOM and an i5). You will see it if it works or not ... ;-)
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Thu Dec 07, 2023 7:52 pm    Post subject: Reply with quote

pietinger wrote:
Joseph_sys wrote:
The kernel on SSD-drive was edited just to run the system, but I did not do any customization, in my opinion it should run in i5-Intel,

What GDH-gentoo has meant is: With Gentoo you can compile all applications for a specific CPU - e.g. if you have in your make.conf:
Code:
COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
...

Now you want run applications which have been compiled for the instruction set of an ATOM CPU ... yes, both CPUs are Intel CPUs ... yes, it could be that the machine language an old ATOM understands will be understand also from a newer i5 ... but it could be possible that the ATOM has some instructions an i5 dont understand ... then every applications which uses this instruction(s) (=have been compiled using these) will give you a "illegal instruction" in your dmesg and will break (sorry, I am not a CPU expert knowing the instructions set of an ATOM and an i5). You will see it if it works or not ... ;-)


I see, on SSD make.conf has:
Code:
CFLAGS="-march=core2 -O2 -pipe"
CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3"
...

But, I think I'm not there yet. At least I should see some kernel booting lines on the screen during boot but I don't see anything.
I was checking "os-prober", booted from NVMe-drive and running it detected OS on SSD /dev/sda1
Code:
i5_new /home/fd # os-prober
/dev/sda3:Gentoo/Linux:Gentoo:linux

/dev/sda3 is "root" directory on SSD
Now, running:
Code:
grub-mkconfig -o /boot/grub/grub.cfg

will it pull/install "kernel-current" from SSD-disk /boot/ to NVMe-disk /boot/grub.cfg?
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1548
Location: South America

PostPosted: Thu Dec 07, 2023 7:55 pm    Post subject: Reply with quote

Not only the compilation flags. I also meant, for example, kernel configuration options for hardware or features that maybe were disabled because the Atom computer's hardware didn't need them (e. g. anything UEFI-related, given that it was a BIOS computer), but the i5 computer's hardware might need enabled. Did you do something like that? How 'generic' is kernel-current's configuration?
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Thu Dec 07, 2023 8:34 pm    Post subject: Reply with quote

GDH-gentoo wrote:
Not only the compilation flags. I also meant, for example, kernel configuration options for hardware or features that maybe were disabled because the Atom computer's hardware didn't need them (e. g. anything UEFI-related, given that it was a BIOS computer), but the i5 computer's hardware might need enabled. Did you do something like that? How 'generic' is kernel-current's configuration?


What do you mean "generic", here is a link to the "config-current" file from SSD:
Is there anything that would need to be enabled?
https://file.io/9CcK93ieV2Ef
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Thu Dec 07, 2023 8:43 pm    Post subject: Reply with quote

Joseph_sys wrote:

Code:
i5_new /home/fd # os-prober
/dev/sda3:Gentoo/Linux:Gentoo:linux

/dev/sda3 is "root" directory on SSD
Now, running:
Code:
grub-mkconfig -o /boot/grub/grub.cfg

will it pull/install "kernel-current" from SSD-disk /boot/ to NVMe-disk /boot/grub.cfg?


os-prober detected the second bootable drive but "grub-mkconfig -o /boot/grub/grub.cfg" did not install any entry from it:
Code:
grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.57-gentoo
Found linux image: /boot/vmlinuz-6.1.57-gentoo.old
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


In addition I did not find any line "GRUB_DISABLE_OS_PROBER" in /etc/default/grub
Code:
cat /etc/default/grub | grep 'GRUB_DISABLE_OS_PROBER'
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4236
Location: Bavaria

PostPosted: Thu Dec 07, 2023 9:29 pm    Post subject: Reply with quote

Joseph_sys wrote:
In addition I did not find any line "GRUB_DISABLE_OS_PROBER" in /etc/default/grub

Have you tried just throwing "GRUB_DISABLE_OS_PROBER=false" into /etc/default/grub ?
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Thu Dec 07, 2023 9:49 pm    Post subject: Reply with quote

pietinger wrote:
Joseph_sys wrote:
In addition I did not find any line "GRUB_DISABLE_OS_PROBER" in /etc/default/grub

Have you tried just throwing "GRUB_DISABLE_OS_PROBER=false" into /etc/default/grub ?


Good hint, did realize it. Yes, it did something after I added manually "GRUB_DISABLE_OS_PROBER=false" as you suggested, output:
Code:
grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.57-gentoo
Found linux image: /boot/vmlinuz-6.1.57-gentoo.old
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Gentoo/Linux on /dev/sda3
Adding boot menu entry for UEFI Firmware Settings ...
done

So it add menu entry and upon rebooting I see the entry. When I select it, it prints "can not find: kernel-current"

Code:
menuentry 'Gentoo/Linux (on /dev/sda3)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/kernel-current--88>
                insmod part_gpt
                insmod ext2
                set root='hd0,gpt3'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d>
                else
                  search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
                fi
                linux /boot/kernel-current root=/dev/sda3

The disk "uuid" is correct.

I forgot to mention, I mount SSD from entry in NVMe-disk fstab:
Code:
# temporary entry for /dev/sda drive
/dev/sda1          /atom/efi        vfat           noauto,noatime   1 2
/dev/sda3      /atom      ext4      noatime      0 1

But I don't think it has anything to do with booting as boot should be looking for in from disk "UUID" isn't it?
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Fri Dec 08, 2023 12:31 am    Post subject: Reply with quote

I tried to manually change/modify the last line in grub.cfg
Code:
from:
linux /boot/kernel-current root=/dev/sda3

to:
linux /boot/kernel-current root=PARTUUID=fa8c4c1e-572c-4338-a4be-3eeb21be0ef1 ro


similar to my entry that works on MVMe-disk in grub.cfg
but it didn't work either, can not find the kernel-current
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


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

PostPosted: Fri Dec 08, 2023 1:37 am    Post subject: Reply with quote

Joseph_sys wrote:
I tried to manually change/modify the last line in grub.cfg
Code:
from:
linux /boot/kernel-current root=/dev/sda3

to:
linux /boot/kernel-current root=PARTUUID=fa8c4c1e-572c-4338-a4be-3eeb21be0ef1 ro


similar to my entry that works on MVMe-disk in grub.cfg
but it didn't work either, can not find the kernel-current


You are going on wrong direction :(

The message said "can not find: kernel-current". Base on your post of grub configuration fragment, grub is looking for a device with gpt PARTITION LABEL, on its 3rd partition, set it as root variable's value and assume it is ext2 filesystem, in the ext2 fileystem there is a directory name "boot" and in the boot directory there is file name "kernel-current" therefor the line "linux /boot/kernel-current ..."

So question are, in your SSD device is there partition number 3? is the partition 3 have a sub directory name "boot"? and in the boot directory have file name "kernel-current"?

I am no grub expert, but just based on the fragment code and the error message it seems telling grub not able to find the file, I don't think it is linux not able to find its root file system yet.
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Fri Dec 08, 2023 1:56 am    Post subject: Reply with quote

pingtoo wrote:
[snip...]
You are going on wrong direction :(

The message said "can not find: kernel-current". Base on your post of grub configuration fragment, grub is looking for a device with gpt PARTITION LABEL, on its 3rd partition, set it as root variable's value and assume it is ext2 filesystem, in the ext2 fileystem there is a directory name "boot" and in the boot directory there is file name "kernel-current" therefor the line "linux /boot/kernel-current ..."

So question are, in your SSD device is there partition number 3? is the partition 3 have a sub directory name "boot"? and in the boot directory have file name "kernel-current"?

I am no grub expert, but just based on the fragment code and the error message it seems telling grub not able to find the file, I don't think it is linux not able to find its root file system yet.


Code:
lsblk -f
NAME        FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                               
├─sda1      vfat   FAT32       9D89-3968                                           
├─sda2      swap   1           8ea5eb4a-2d12-4c12-bb3e-d11241dc2730               
├─sda3      ext4   1.0         88f8a211-f72b-4294-85ef-d6b93697286d  196.4G    50% /atom
└─sda4      vfat   FAT32       5DC1-B636                                           
nvme0n1                                                                           
├─nvme0n1p1 vfat   FAT32       03FD-4F30                                           
├─nvme0n1p2 swap   1           67d076c6-5273-454f-8ed0-83f3b96e15a3                [SWAP]
└─nvme0n1p3 ext4   1.0         0a0b75fc-3405-490c-a8fc-e3092a686cf3  854.5G     1% /


I don't know what "ext2" refers to, I do not use ext2 anywhere.

"kernel-current" is in /dev/sda3 /boot directory, it is ext4

Here is complete /boot/grub/grub.cfg from NVMe-drive:
Code:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 0a0b75fc-3405-490c-a8fc-e3092a686cf3
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0a0b75fc-3405-490c-a8fc-e3092a686cf3' {
   load_video
   if [ "x$grub_platform" = xefi ]; then
      set gfxpayload=keep
   fi
   insmod gzio
   insmod part_gpt
   insmod ext2
   search --no-floppy --fs-uuid --set=root 0a0b75fc-3405-490c-a8fc-e3092a686cf3
   echo   'Loading Linux 6.1.57-gentoo ...'
   linux   /boot/vmlinuz-6.1.57-gentoo root=PARTUUID=d75dfcd4-7534-7347-92e0-dc74e290ca4e ro 
}
submenu 'Advanced options for Gentoo GNU/Linux' $menuentry_id_option 'gnulinux-advanced-0a0b75fc-3405-490c-a8fc-e3092a686cf3' {
   menuentry 'Gentoo GNU/Linux, with Linux 6.1.57-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.57-gentoo-advanced-0a0b75fc-3405-490c-a8fc-e3092a686cf3' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      search --no-floppy --fs-uuid --set=root 0a0b75fc-3405-490c-a8fc-e3092a686cf3
      echo   'Loading Linux 6.1.57-gentoo ...'
      linux   /boot/vmlinuz-6.1.57-gentoo root=PARTUUID=d75dfcd4-7534-7347-92e0-dc74e290ca4e ro 
   }
   menuentry 'Gentoo GNU/Linux, with Linux 6.1.57-gentoo (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.57-gentoo-recovery-0a0b75fc-3405-490c-a8fc-e3092a686cf3' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      search --no-floppy --fs-uuid --set=root 0a0b75fc-3405-490c-a8fc-e3092a686cf3
      echo   'Loading Linux 6.1.57-gentoo ...'
      linux   /boot/vmlinuz-6.1.57-gentoo root=PARTUUID=d75dfcd4-7534-7347-92e0-dc74e290ca4e ro single
   }
   menuentry 'Gentoo GNU/Linux, with Linux 6.1.57-gentoo.old' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.57-gentoo.old-advanced-0a0b75fc-3405-490c-a8fc-e3092a686cf3' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      search --no-floppy --fs-uuid --set=root 0a0b75fc-3405-490c-a8fc-e3092a686cf3
      echo   'Loading Linux 6.1.57-gentoo.old ...'
      linux   /boot/vmlinuz-6.1.57-gentoo.old root=PARTUUID=d75dfcd4-7534-7347-92e0-dc74e290ca4e ro 
   }
   menuentry 'Gentoo GNU/Linux, with Linux 6.1.57-gentoo.old (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.57-gentoo.old-recovery-0a0b75fc-3405-490c-a8fc-e3092a686cf3' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      search --no-floppy --fs-uuid --set=root 0a0b75fc-3405-490c-a8fc-e3092a686cf3
      echo   'Loading Linux 6.1.57-gentoo.old ...'
      linux   /boot/vmlinuz-6.1.57-gentoo.old root=PARTUUID=d75dfcd4-7534-7347-92e0-dc74e290ca4e ro single
   }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Gentoo/Linux (on /dev/sda3)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-88f8a211-f72b-4294-85ef-d6b93697286d' {
   insmod part_gpt
   insmod ext2
   set root='hd0,gpt3'
   if [ x$feature_platform_search_hint = xy ]; then
     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d6b93697286d
   else
     search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
   fi
   linux /boot/kernel-old root=/dev/sda3
}
submenu 'Advanced options for Gentoo/Linux (on /dev/sda3)' $menuentry_id_option 'osprober-gnulinux-advanced-88f8a211-f72b-4294-85ef-d6b93697286d' {
   menuentry 'Gentoo/Linux (on /dev/sda3)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/kernel-old--88f8a211-f72b-4294-85ef-d6b93697286d' {
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt3'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d6b93697286d
      else
        search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
      fi
      linux /boot/kernel-old root=/dev/sda3
   }
   menuentry 'Gentoo/Linux (on /dev/sda3)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/kernel-current--88f8a211-f72b-4294-85ef-d6b93697286d' {
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt3'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d6b93697286d
      else
        search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
      fi
      linux /boot/kernel-current root=/dev/sda3
   }
}

### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
   fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###


And yes, both disk label are: GPT
Code:
fdisk -l
Disk /dev/nvme0n1: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 970 EVO Plus 1TB           
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: F143D933-EFE1-DB4F-AC52-5E250B36396C

Device            Start        End    Sectors   Size Type
/dev/nvme0n1p1     2048    2099199    2097152     1G EFI System
/dev/nvme0n1p2  2099200   10487807    8388608     4G Linux swap
/dev/nvme0n1p3 10487808 1953523711 1943035904 926.5G Linux filesystem


Disk /dev/sda: 447.13 GiB, 480103981056 bytes, 937703088 sectors
Disk model: INTEL SSDSC2BF48
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: F38D1AEB-150D-4290-8202-494971D3659C

Device         Start       End   Sectors   Size Type
/dev/sda1       2048    155647    153600    75M EFI System
/dev/sda2     155648   4349951   4194304     2G Linux swap
/dev/sda3    4349952 937697279 933347328 445.1G Linux filesystem
/dev/sda4  937697280 937703054      5775   2.8M EFI System
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1548
Location: South America

PostPosted: Fri Dec 08, 2023 11:26 am    Post subject: Reply with quote

Joseph_sys wrote:
I forgot to mention, I mount SSD from entry in NVMe-disk fstab:
Code:
# temporary entry for /dev/sda drive
/dev/sda1          /atom/efi        vfat           noauto,noatime   1 2
/dev/sda3      /atom      ext4      noatime      0 1

Could you post the output of ls -1 /atom/boot? Based on the contents of grub.cfg, it seems that os-prober can't find kernel-current either (you had to edit the file), it only sees kernel-old.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4236
Location: Bavaria

PostPosted: Fri Dec 08, 2023 11:58 am    Post subject: Reply with quote

IF your old installation on SSD had an extra partition for your kernel (and you have mounted it to /boot of your root directory) THEN ... the kernel resides in the root directory of this partition ... only after mounting it to /boot you will see it as "/boot/kernel-current" ... but grub looks to the unmounted boot-partition and see the kernel in /kernel-current

So try to change this ... and now you have the perfect template to take path 2 ... ;-)

Code:
menuentry 'Gentoo/Linux (on /dev/sda3)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/kernel-current--88>
                insmod part_gpt
                insmod ext2
                set root='hd0,gpt3'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d>
                else
                  search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
                fi
                linux /kernel-current root=/dev/sda3

_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4236
Location: Bavaria

PostPosted: Fri Dec 08, 2023 12:07 pm    Post subject: Reply with quote

pingtoo wrote:
[...] I am no grub expert, but just based on the fragment code and the error message it seems telling grub not able to find the file, I don't think it is linux not able to find its root file system yet.

I am also no grub expert, but I think you are absolutely correct here.
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1548
Location: South America

PostPosted: Fri Dec 08, 2023 12:26 pm    Post subject: Reply with quote

pietinger wrote:
IF your old installation on SSD had an extra partition for your kernel (and you have mounted it to /boot of your root directory) THEN ... the kernel resides in the root directory of this partition ... [...]

Code:
menuentry 'Gentoo/Linux (on /dev/sda3)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/kernel-current--88>
                insmod part_gpt
                insmod ext2
                set root='hd0,gpt3'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d>
                else
                  search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
                fi
                linux /kernel-current root=/dev/sda3

In that case, this won't work as-is because the filesystem UUID given to the search command that sets the root environment variable (for resolving GRUB relative pathnames) is still that of the 3rd partition of the SSD.

I wonder what that 4th partition with a FAT filesystem (i. e. /dev/sda4 for the kernel) is...
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4236
Location: Bavaria

PostPosted: Fri Dec 08, 2023 12:30 pm    Post subject: Reply with quote

GDH-gentoo wrote:
In that case, this won't work as-is because the filesystem UUID given to the search command that sets the root environment variable (for resolving GRUB relative pathnames) is still that of the 3rd partition of the SSD.

I wonder what that 4th partition with a FAT filesystem (i. e. /dev/sda4 for the kernel) is...

Yes, you are right (as always :D ) ... I have not looked at the UUID ... :oops:
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Fri Dec 08, 2023 2:59 pm    Post subject: Reply with quote

GDH-gentoo wrote:
Joseph_sys wrote:
I forgot to mention, I mount SSD from entry in NVMe-disk fstab:
Code:
# temporary entry for /dev/sda drive
/dev/sda1          /atom/efi        vfat           noauto,noatime   1 2
/dev/sda3      /atom      ext4      noatime      0 1

Could you post the output of ls -1 /atom/boot? Based on the contents of grub.cfg, it seems that os-prober can't find kernel-current either (you had to edit the file), it only sees kernel-old.


Here it is:
Code:
ls -1 /atom/boot
System.map-current
System.map-old
config-current
config-old
grub
kernel-current
kernel-old


I tried booting both, I get the same message: /boot/kernel-old file not found
/boot/kernel-current file not found
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


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

PostPosted: Fri Dec 08, 2023 3:03 pm    Post subject: Reply with quote

Joseph_sys,

I am assume "ext2" mean only support ext2fs. It looks like it is a all inclusive name for all ext2/ext3/ext4. That show how much I know about Grub :oops:

It looks like we will need to drop in to Grub command line to debug.

when you are available, please try to boot and use 'c' to drop in to Grub command then, type in "set root=(" follow by TAB key to see what devices available to choose. We will need to see how you system boot arrange storage device order.

after above testing, we can also test with "ls" command to see how Grub view storage content.
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Fri Dec 08, 2023 3:11 pm    Post subject: Reply with quote

pietinger wrote:
IF your old installation on SSD had an extra partition for your kernel (and you have mounted it to /boot of your root directory) THEN ... the kernel resides in the root directory of this partition ... only after mounting it to /boot you will see it as "/boot/kernel-current" ... but grub looks to the unmounted boot-partition and see the kernel in /kernel-current

So try to change this ... and now you have the perfect template to take path 2 ... ;-)

Code:
menuentry 'Gentoo/Linux (on /dev/sda3)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/kernel-current--88>
                insmod part_gpt
                insmod ext2
                set root='hd0,gpt3'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d>
                else
                  search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
                fi
                linux /kernel-current root=/dev/sda3


I tried as you suggested:
Code:
from:
linux /boot/kernel-current root=/dev/sda3

to:
linux /kernel-current root=/dev/sda3


still same message: '/kernel-current' not found
[/code]
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2712
Location: Edmonton, AB

PostPosted: Fri Dec 08, 2023 3:38 pm    Post subject: Reply with quote

pingtoo wrote:
Joseph_sys,

I am assume "ext2" mean only support ext2fs. It looks like it is a all inclusive name for all ext2/ext3/ext4. That show how much I know about Grub :oops:

It looks like we will need to drop in to Grub command line to debug.

when you are available, please try to boot and use 'c' to drop in to Grub command then, type in "set root=(" follow by TAB key to see what devices available to choose. We will need to see how you system boot arrange storage device order.

after above testing, we can also test with "ls" command to see how Grub view storage content.


Good suggestion, here is the result:
Code:
grub> set root=(
Possible devices are:

proc hd0


OK, how do I read it? "hd0"= /dev/sda3
Where is NVMe-disk ?

But looking at the boot entry menu generated by grub (that works) on NVMe-disk:
Code:
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0a0b75fc-3405-490c-a8fc-e3092a686cf3' {
   load_video
   if [ "x$grub_platform" = xefi ]; then
      set gfxpayload=keep
   fi
   insmod gzio
   insmod part_gpt
   insmod ext2
   search --no-floppy --fs-uuid --set=root 0a0b75fc-3405-490c-a8fc-e3092a686cf3
   echo   'Loading Linux 6.1.57-gentoo ...'
   linux   /boot/vmlinuz-6.1.57-gentoo root=PARTUUID=d75dfcd4-7534-7347-92e0-dc74e290ca4e ro


and comparing it to boot entry menu generated by 'os-prober' script, they look a lot different:
Code:
   menuentry 'Gentoo/Linux (on /dev/sda3)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/kernel-current--88f8a211-f72b-4294-85ef-d6b93697286d' {
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt3'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  88f8a211-f72b-4294-85ef-d6b93697286d
      else
        search --no-floppy --fs-uuid --set=root 88f8a211-f72b-4294-85ef-d6b93697286d
      fi
      linux /boot/kernel-current root=/dev/sda3


Last edited by Joseph_sys on Fri Dec 08, 2023 3:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4236
Location: Bavaria

PostPosted: Fri Dec 08, 2023 3:45 pm    Post subject: Reply with quote

at least one "insmod gzio" is probably missing ... to be able to unpack the kernel ... maybe this is the cause of the error message that grub cannot find the kernel ?
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


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

PostPosted: Fri Dec 08, 2023 3:52 pm    Post subject: Reply with quote

Joseph_sys wrote:


Good suggestion, here is the result:
Code:
grub> set root=(
Possible devices are:

proc hd0


There is problem, I would expect there should be hd0 and hd1 or whatever grub choose to name your storage device. It seems to me there could be missing driver in grub to read the SSD or something not pass to grub to detect there is second storage device, will need to do more research to find what else need to do.

In the mean time you can try pietinger suggestion add "insmod gzio" to see if that help.
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
Goto page 1, 2, 3  Next
Page 1 of 3

 
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