You are not logged in.

#1 2025-01-09 15:17:29

linuxghost
Member
Registered: 2017-06-16
Posts: 23

[SOLVED]Grub problem after successful migration from /boot

I was al little premature marking this topic [SOLVED] though, thanks to Awebb and cryptearth ¾ is solved and I have succeeded in moving the kernels from the ESP to /boot. See here... System runs fine, even after the kernelupdate.
Problems started when I tried to change the grub-font into one that shouldn't need a magnifying glass. And after adding the lts kernel;

sudo grub-mkconfig -o /boot/efi/grub/grub.cfg

did not produce any output.
Also my attempt to install grub (under /boot, rather than /boot/efi)

grub-install --target=x86_64-efi --efi-directory=/boot/--bootloader-id=GRUB

failed with also no output.

This time the problem cannot be solved on a running system?

Last edited by linuxghost (2025-01-13 19:34:10)


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#2 2025-01-09 15:39:56

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,901

Re: [SOLVED]Grub problem after successful migration from /boot

grub-mkconfig will write that file and not provide output.

if you're indeed using the grub installed by the line as pasted here then grub still looks for it's config under /boot/grub so the correct invocation would be

sudo grub-mkconfig -o /boot/grub/grub.cfg

Do you want grub to store it's config on the ESP or on your root partition in /boot ? The Invocation

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

will generate a GRUB entry on the ESP in /boot/efi that checks for it's configuration in /boot/grub (which doesn't have to be on the ESP) if you want to change the config directory you need to add --boot-directory=/boot/efi like so

grub-install --target=x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot/efi --bootloader-id=GRUB

which will generate an entry that checks the config under /boot/efi/grub instead

Offline

#3 2025-01-09 15:40:36

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,323

Re: [SOLVED]Grub problem after successful migration from /boot

If the ESP is at /boot/efi now, why are you telling grub-install it's at /boot?

/boot/efi/grub/grub.cfg is nothing, why are you putting the config there? Grub will never see it.

Online

#4 2025-01-09 15:46:09

cryptearth
Member
Registered: 2024-02-03
Posts: 1,223

Re: [SOLVED]Grub problem after successful migration from /boot

v1del already gave all needed info
I'd like to add: maybe first clean up both /boot and /efi
also: no output is usually ok - same with "return 0 on success" - just you don't get anything back doesn't mean it failed - in fact for most posix tools its default to only output errors when something failed but no confirmation on success
grub-mkconfig on the otherhand usually should print some output - getting nothin at all from it sounds a bit odd

Offline

#5 2025-01-09 16:27:03

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

cryptearth wrote:

grub-mkconfig on the otherhand usually should print some output - getting nothin at all from it sounds a bit odd
I'd like to add: maybe first clean up both /boot and /efi

Yes, that grub-mkconfig should produce output is also my experience. So not producing output but waiting "forever" untill Ctrl-C is odd indeed and makes me wonder...

How to clean /efi (because /boot really doesn't need cleaning as that's only where the kernels and vmlinux lives..)
Best way via  Windows??

Last edited by linuxghost (2025-01-09 18:56:32)


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#6 2025-01-09 17:03:11

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

V1del wrote:

grub-mkconfig will write that file and not provide output.

Thank you for your reply but IMHO it should. The date didn't change.

V1del wrote:

if you're indeed using the grub installed by the line as pasted here then grub still looks for it's config under /boot/grub so the correct invocation would be

sudo 
grub-mkconfig -o /boot/grub/grub.cfg

Tried that command too, also didn't produce output. So my thoughts then were to (re)create the grub.cfg where it was found (under /boot/efi).

V1del wrote:

Do you want grub to store it's config on the ESP or on your root partition in /boot ? The Invocation

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

will generate a GRUB entry on the ESP in /boot/efi that checks for it's configuration in /boot/grub (which doesn't have to be on the ESP) if you want to change the config directory you need to add --boot-directory=/boot/efi like so

grub-install --target=x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot/efi --bootloader-id=GRUB

which will generate an entry that checks the config under /boot/efi/grub instead

The grub.cfg can now be found under /boot/efi/grub. So to make the installation more "conform" wouldn't it be better to also migrate grub from /boot/efi to /boot?

If so, how do I proceed??

Also what is the minimum grub needs on the ESP (to reduce the risk Windows messes up...)


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#7 2025-01-09 17:17:27

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Scimmia wrote:

If the ESP is at /boot/efi now, why are you telling grub-install it's at /boot?

/boot/efi/grub/grub.cfg is nothing, why are you putting the config there? Grub will never see it.

Thank you for your reply.

If grub doesn't see it there (where the installation put it; /boot/efi/grub/grub.cfg), where does grub see it?

Strange though that somehow the kernelupdate went smoothly after the migration of the kernels from /boot/efi (on the ESP) to /boot (on /)


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#8 2025-01-09 17:19:07

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,901

Re: [SOLVED]Grub problem after successful migration from /boot

the minimum grub needs is the GRUB EFI binary which happens when you do

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

that will only install a single necessary file under /boot/efi/EFI/GRUB/grubx64.efi -- the rest of the config and setup will then land in /boot/grub -- which isn't your EFI anymore.

as for "no output of the command", that sounds like a wonky shell config or so... are you using oh-I-broke-my-zsh or so? assuming your stuff is mounted like you think it's correct what output do you get from

mount
ls -l /boot /boot/efi

Offline

#9 2025-01-09 18:50:59

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

V1del wrote:

as for "no output of the command", that sounds like a wonky shell config or so... are you using oh-I-broke-my-zsh or so? assuming your stuff is mounted like you think it's correct what output do you get from

mount
ls -l /boot /boot/efi

The command in bash also doesn't produce any output (it waits forever, only Ctrl-C halts it). I used zsh for more than a year, never a problem...
Here the output requested;

mount 
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
dev on /dev type devtmpfs (rw,nosuid,relatime,size=16018536k,nr_inodes=4004634,mode=755,inode64)
run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755,inode64)
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/nvme1n1p5 on / type ext4 (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=40,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=9328)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,nosuid,nodev,relatime,pagesize=2M)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/credentials/systemd-journald.service type tmpfs (ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=16063204k,nr_inodes=1048576,inode64)
/dev/nvme1n1p1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/nvme0n1p3 on /home type ext4 (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=3212640k,nr_inodes=803160,mode=700,uid=1000,gid=984,inode64)
portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=984)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=984)
tracefs on /sys/kernel/debug/tracing type tracefs (rw,nosuid,nodev,noexec,relatime) 
ls -l /boot /boot/efi                                                                                                                     18:25:55 

/boot:
totaal 433372
drwxr-xr-x 5 root root      4096  1 jan  1970 efi
-rw------- 1 root root 152567589  9 jan 09:33 initramfs-linux-fallback.img
-rw------- 1 root root  84996414  9 jan 09:32 initramfs-linux.img
-rw------- 1 root root 100929089  9 jan 09:32 initramfs-linux-lts-fallback.img
-rw------- 1 root root  78365571  9 jan 09:32 initramfs-linux-lts.img
-rw-r--r-- 1 root root  13812224  4 jan 11:19 vmlinuz-linux
-rw-r--r-- 1 root root  13074944  4 jan 11:19 vmlinuz-linux-lts

/boot/efi:
totaal 164
-rwxr-xr-x 1 root root 153600 10 dec 20:35  amd-ucode.img
drwxr-xr-x 5 root root   4096 29 dec 18:32  EFI
drwxr-xr-x 6 root root   4096  1 jan 16:46  grub
drwxr-xr-x 2 root root   4096 18 dec 11:37 'System Volume Information'

amd-ucode.img is ok on the ESP? Or also migrate to /boot?

Simply moving grub from /boot/efi to /boot is too simplistic?

Last edited by linuxghost (2025-01-09 18:54:51)


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#10 2025-01-09 22:35:43

cryptearth
Member
Registered: 2024-02-03
Posts: 1,223

Re: [SOLVED]Grub problem after successful migration from /boot

there seems quite a confusion - hence I recommend to clean both /boot and (/boot)/efi
by clean I mean to wipe everything except <ESP>\Microsoft (which in your case resolves to /boot/efi/Microsoft) as, thanks god, M$ did at least that part right (although it keeps overwriting <ESP>\Boot\Bootx64.efi no matter if that's a foreign binary)
next you should clean your boot entries with efibootmgr so it only contains the entry <ESP>\Microsoft\Boot\bootmgfw.efi (or whatever that's called exactly)
then - without reboot - cleanly install the kernel and initrd by invoking pacman: pacman -S linux ucode - which will copy the kernel, the initrd and the ucode where it belongs in /boot
after that's in place finally reinstall grub
be aware of the parameter --boot-directory=: when not given it defaults to /boot so both the additional files as well as the config land in /boot and only the efi binary on the esp in /boot/efi
if however you give --boot-directory=/boot/efi then all of grub will be installed on the esp - and so has the config to be placed at /boot/efi/grub/grub.cfg

you also can place /efi outside of /boot and even use an additional partition for /boot (so called xbootldr)

this can all be done both from within the running system as well via install media and chroot - what and how you do it is up to you

fun fact: you can also generate an UKI, copy it onto the ESP and add an entry in windows BCD and don't use grub at all - but that's out of the scope of this forum

Offline

#11 2025-01-10 10:27:45

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Thanks for this reply cryptearth. So this is what I have to do;

1.

efibootmgr --delete-bootnum 0002

(\EFI\GRUB\grubx64.cfg)

2. Manually remove /boot/efi/grub directory (so now /boot/efi is clean)

3. Manually remove the initramfs's and vmlinuzes that were mkinitcpio-ed in /boot (now /boot is clean)

4.

pacman -S linux amd-ucode

(does it reinstall?)

5.

grub-install --target=x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=GRUB

(so grub lands in /boot)

6. reboot  OR

grub-mkconfig -o /boot/grub/grub.cfg

first?

Last edited by linuxghost (2025-01-10 10:28:13)


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#12 2025-01-10 12:22:32

cryptearth
Member
Registered: 2024-02-03
Posts: 1,223

Re: [SOLVED]Grub problem after successful migration from /boot

looks good to me

for 4: yes, this will reinstall kernel and ucode and should also call mkinitcpio so you end uo with kernel, initramfs and ucode all in place in /boot for mkconfig to detect

for 5: the efi binary itself will be installed in /boot/efi/EFI/GRUB/grubx64.efi while the rest of its files and config will end up in /boot/grub/...

for 6: first generate new config then reboot - otherwise you'll end up in grub rescue due to no config

if all goes well you should recheck with efibootmgr that the entey is correct and check the new boot order - as grub-install just calls efibootmgr as helper there's no explicit defined behaviour how the new boot order will end up

Offline

#13 2025-01-11 19:14:43

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Well... that went good up to and including 4;
5: grub-install  (again) produced no output but a blinking cursor for a long time then, after an even longer time, produced

/bin/sh: warning: shell level (1000) too high, resetting to 1

same as grub-mkconfig...

So I thought to boot from the install usb, mount / and /boot/efi and with the shell from the install media

 grub-install --target=x86_64-efi --efi-directory=/mnt/boot/efi --boot-directory=/mnt/boot --bootloader-id=GRUB

and that installed the grub directory right under /boot. OK!

So now I'm only one command away from the solution...

But I don't know how to grub-mkconfig "externally" the same way I did with grub-install.
I remember V1del's answer;

V1del wrote:

as for "no output of the command", that sounds like a wonky shell config or so... are you using oh-I-broke-my-zsh or so? assuming your stuff is mounted like you think it's correct what output do you ...

I switched back from zsh to bash to rule zsh out.
How can I rule other criiters out?


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#14 2025-01-11 23:04:19

cryptearth
Member
Registered: 2024-02-03
Posts: 1,223

Re: [SOLVED]Grub problem after successful migration from /boot

well - the install working "from extern" sounds odd as it not uses the grub of the installed system but rather something from the live environment

mkconfig will likely fail as, at least to my knowledge, it has to be run from within chroot

have you tried to reinstall grub? I'm not sure how but maybe it somehow became corrupted? quite a strange issue

Offline

#15 2025-01-12 10:16:58

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Yes I have reinstalled grub multiple times.

Is it possible that "somewhere something" of the former setup of this laptop has survived?
That only changing the /boot entry to /boot/efi in fstab was not enough?

Speaking of which; strange mountoptions in fstab of /boot/efi caught my attention. It was generated with genfstab during the installation;

UUID=7439-71DE          /boot/efi       vfat            rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro   0 2

Especially compared to the same, much simpeler line on my old laptop (with gnome)

 UUID=???   /boot/efi            vfat       defaults,noatime    0  2

and from the partition where I installed kde

 UUID=???   /boot/efi            vfat       defaults,umask=0077   0  2

Now wouldn't grub-install as well as grub-mkconfig fail when /boot/efi was remounted ro?


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#16 2025-01-12 11:13:41

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,738
Website

Re: [SOLVED]Grub problem after successful migration from /boot

You don't need grub-mkconfig to create a working grub.cfg, the format is very simple: one line to identify the partition holding the kernel & initramfs, one line giving the path to the kernel followed by the kernel command line parameteres (which includes the location of the root partition) and one line giving the path to the ucode & initramfs images. That's it.

So this content in /boot/grub/grub.cfg would do it:

search --fs-uuid --set=root $uuid
linux /boot/vmlinuz-linux root=UUID=$uuid ro quiet
initrd /boot/amd-ucode.img /boot/initramfs-linux.img
boot

Replace $uuid with the actual filesystem UUID of the root partition. Add any extra kernel parameters to the end of the second line.

The error message references /bin/sh so check that is still a symlink to /bin/bash in the installed system.


Para todos todo, para nosotros nada

Offline

#17 2025-01-12 12:31:03

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Head_on_a_Stick wrote:

You don't need grub-mkconfig to create a working grub.cfg, the format is very simple: one line to identify the partition holding the kernel & initramfs, one line giving the path to the kernel followed by the kernel command line parameteres (which includes the location of the root partition) and one line giving the path to the ucode & initramfs images. That's it.

Worked like a charm. Beats entering commands at the grub prompt say the least. wink

Back to the grub-mkconfig issue again:

Head_on_a_Stick wrote:

The error message references /bin/sh so check that is still a symlink to /bin/bash in the installed system.

/bin/sh is not a symlink to /bin/bash, it got (standard?) installed.

sh-5.2$ cat /etc/shells 
# Pathnames of valid login shells.
# See shells(5) for details.

/bin/sh
/bin/bash
/bin/rbash
/usr/bin/sh
/usr/bin/bash
/usr/bin/rbash
/usr/bin/systemd-home-fallback-shell
/usr/bin/git-shell
/bin/zsh
/usr/bin/zsh

___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#18 2025-01-12 13:24:04

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,738
Website

Re: [SOLVED]Grub problem after successful migration from /boot

linuxghost wrote:

/bin/sh is not a symlink to /bin/bash

Well it should be. Try reinstalling the bash package.


Para todos todo, para nosotros nada

Offline

#19 2025-01-12 14:28:53

cryptearth
Member
Registered: 2024-02-03
Posts: 1,223

Re: [SOLVED]Grub problem after successful migration from /boot

linuxghost wrote:

Yes I have reinstalled grub multiple times.

I don't mean installing grub with grub-install but rather the package with pacman -S grub
but the shell error could also be an issue

Offline

#20 2025-01-12 17:18:34

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

cryptearth wrote:
linuxghost wrote:

Yes I have reinstalled grub multiple times.

I don't mean installing grub with grub-install but rather the package with pacman -S grub
but the shell error could also be an issue

Thank you for your reply.
Yes, pacman -S grub was what I did multiple times.
Right now I'm browsing through the pacman log to see if there is anyting out of the ordinary.


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#21 2025-01-12 19:26:39

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Head_on_a_Stick wrote:
linuxghost wrote:

/bin/sh is not a symlink to /bin/bash

Well it should be. Try reinstalling the bash package.

Reinstalling bash didn't make a difference (unless it does after a reboot?).
BTW I never installed sh explicitly (according to the pacman log) isn't sh part of the base metapackage?
If my memory serves me well I did a pacstrap.


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#22 2025-01-12 19:39:23

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,738
Website

Re: [SOLVED]Grub problem after successful migration from /boot

/bin/sh is created by the bash package: https://gitlab.archlinux.org/archlinux/ … heads#L174

Just to be sure can we see the output of this command from the running system:

ls -l /bin/sh

Please also confirm the same error message occurs when running grub-mkconfig from the running system. Thanks.


Para todos todo, para nosotros nada

Offline

#23 2025-01-13 10:49:06

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Head_on_a_Stick wrote:

/bin/sh is created by the bash package: https://gitlab.archlinux.org/archlinux/ … heads#L174

Just to be sure can we see the output of this command from the running system:

ls -l /bin/sh

Please also confirm the same error message occurs when running grub-mkconfig from the running system. Thanks.

Thank you for your reply.
You're absolutely right as much as I was wrong!

 ls -l /bin/sh
lrwxrwxrwx 1 root root 4 24 sep 21:46 /bin/sh -> bash

As for error message; I can confirm that it first occurred on a running system.
And it still occurs, even after reinstallation of bash.
It also occurs in a root-terminal.
grub-mkconfig doesn't have a -v option to be more verbal so there is no feedback.
journalctl only shows that sudo started it, but no result.


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

#24 2025-01-13 10:57:29

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,738
Website

Re: [SOLVED]Grub problem after successful migration from /boot

Check

type grub-mkconfig

Perhaps you're running a wrapper.


Para todos todo, para nosotros nada

Offline

#25 2025-01-13 11:07:08

linuxghost
Member
Registered: 2017-06-16
Posts: 23

Re: [SOLVED]Grub problem after successful migration from /boot

Yes, it shows that

grub-mkconfig is /usr/bin/grub-mkconfig

So there is no wrapper
How can I see where else I'm running a wrapper, where can that be located?

Last edited by linuxghost (2025-01-13 12:03:27)


___________________________o00o_Ꝏ_o00o_______________________

                           Chaos always wins because it is better organised.

Offline

Board footer

Powered by FluxBB