You are not logged in.

#1 2023-07-18 18:03:40

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 186

[SOLVED] Missing GRUB not able to reinstall it

Hello, I had a setup with Arch Linux (btrfs) in dual boot with Windows, and I had GRUB EFI for accessing to them.

Some days ago I tried to install as test an Arch Linux distro on a USB device as persistent installation. After this installation, the previous GRUB is missing and, when the persistent USB is not plugged in, the system boots directly to Windows instead of showing GRUB with the previous Arch and Windows entries.

So, I tried to reinstall GRUB by booting an ISO live of an Arch Linux distro.

sudo fdisk -l returns

Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000LM049-2GH1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 3A6601BB-C377-4A23-A85E-B00A23930E19

Device          Start        End    Sectors   Size Type
/dev/sda1        2048 1724336127 1724334080 822.2G Microsoft basic data
/dev/sda2  1913079808 1953523711   40443904  19.3G Windows recovery environment
/dev/sda3  1724336128 1913079807  188743680    90G Linux filesystem

Partition table entries are not in disk order.


Disk /dev/nvme0n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: KINGSTON RBUSNS8154P3256GJ              
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: A36E6ED1-2B7C-4656-8BDC-35EAE5413530

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      2048    878591    876544   428M EFI System
/dev/nvme0n1p2    878592 498274303 497395712 237.2G Microsoft basic data
/dev/nvme0n1p3 498274304 500117503   1843200   900M Windows recovery environment


Disk /dev/sdb: 3.75 GiB, 4026531840 bytes, 7864320 sectors
Disk model: Flash Disk      
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: dos
Disk identifier: 0x0024edcb

Device     Boot Start     End Sectors  Size Id Type
/dev/sdb1  *     2048 7864319 7862272  3.7G  c W95 FAT32 (LBA)


Disk /dev/loop0: 2.65 GiB, 2849988608 bytes, 5566384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/zram0: 7.73 GiB, 8301051904 bytes, 2026624 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

where "/dev/sda3" is my Arch Linux (btrfs) in dual boot with Windows, and the EFI was installed on "/dev/nvme0n1p1", so it seems that after the install of a Linux system as persistent in USB, the system is not able to see anymore this EFI "/dev/nvme0n1p1".

So I run on terminal

sudo pacman -Syyu
sudo pacman -S arch-install-scripts
sudo mount -o subvol=@ /dev/sda3 /mnt
sudo mount -o subvol=@home /dev/sda3 /mnt/home
sudo mount -o subvol=@log /dev/sda3 /mnt/var/log
sudo mount /dev/nvme0n1p1 /mnt/boot
sudo arch-chroot /mnt
grub-install --target=x86_64-efi --efi-directory=/boot --recheck --modules="part_gpt part_msdos" --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg
exit
reboot

They don't return errors, but when I reboot, the GRUB is still not there.

Just one note: when I run "arch-chroot" I received sometimes this message:

error: process ID out of range

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

Why do I get this message?

About the GRUB reinstall, what am I wrong?

Last edited by D3vil0p3r (2023-07-20 20:22:11)

Offline

#2 2023-07-18 22:16:32

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,809

Re: [SOLVED] Missing GRUB not able to reinstall it

Output of

efibootmgr -uv

?

Offline

#3 2023-07-19 09:18:55

Ferdinand
Member
From: Norway
Registered: 2020-01-02
Posts: 334

Re: [SOLVED] Missing GRUB not able to reinstall it

Go with V1del - these are just my two cents...

  1. You did a pacman -Syyu, so it's possible that you have performed a partial upgrade

  2. If something, somehow, goes wrong when you arch-chroot, then maybe try to install grub without chrooting, by instead adding --boot-directory=/mnt/boot to the grub-install command (and also changing the efi directory accordingly)

Last edited by Ferdinand (2023-07-19 09:23:07)

Offline

#4 2023-07-19 22:51:02

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 186

Re: [SOLVED] Missing GRUB not able to reinstall it

@V1del

BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0002,0000,0001
Boot0000* GRUB	HD(1,GPT,54ffb2ba-81da-4263-ad07-f0921a7d351e,0x800,0xd6000)/File(\EFI\GRUB\GRUBX64.EFI)
      dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 60 0d 00 00 00 00 00 ba b2 ff 54 da 81 63 42 ad 07 f0 92 1a 7d 35 1e 02 02 / 04 04 30 00 5c 00 45 00 46 00 49 00 5c 00 47 00 52 00 55 00 42 00 5c 00 47 00 52 00 55 00 42 00 58 00 36 00 34 00 2e 00 45 00 46 00 49 00 00 00 / 7f ff 04 00
Boot0001* Windows Boot Manager	HD(1,GPT,54ffb2ba-81da-4263-ad07-f0921a7d351e,0x800,0xd6000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)䥗䑎坏S
      dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 60 0d 00 00 00 00 00 ba b2 ff 54 da 81 63 42 ad 07 f0 92 1a 7d 35 1e 02 02 / 04 04 46 00 5c 00 45 00 46 00 49 00 5c 00 4d 00 49 00 43 00 52 00 4f 00 53 00 4f 00 46 00 54 00 5c 00 42 00 4f 00 4f 00 54 00 5c 00 42 00 4f 00 4f 00 54 00 4d 00 47 00 46 00 57 00 2e 00 45 00 46 00 49 00 00 00 / 7f ff 04 00
    data: 57 49 4e 44 4f 57 53 00 01 00 00 00 88 00 00 00 78 00 00 00 42 00 43 00 44 00 4f 00 42 00 4a 00 45 00 43 00 54 00 3d 00 7b 00 39 00 64 00 65 00 61 00 38 00 36 00 32 00 63 00 2d 00 35 00 63 00 64 00 64 00 2d 00 34 00 65 00 37 00 30 00 2d 00 61 00 63 00 63 00 31 00 2d 00 66 00 33 00 32 00 62 00 33 00 34 00 34 00 64 00 34 00 37 00 39 00 35 00 7d 00 00 00 34 00 01 00 00 00 10 00 00 00 04 00 00 00 7f ff 04 00
Boot0002* UEFI: Generic Flash Disk 8.07, Partition 1	PciRoot(0x0)/Pci(0x14,0x0)/USB(1,0)/HD(1,MBR,0x24edcb,0x800,0x77f800)
      dp: 02 01 0c 00 d0 41 03 0a 00 00 00 00 / 01 01 06 00 00 14 / 03 05 06 00 01 00 / 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 f8 77 00 00 00 00 00 cb ed 24 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 / 7f ff 04 00
    data: 00 00 42 4f

@Ferdinand I tried also without pacman -Syyu. Furthermore I tried to do it without arch-chroot and directly on the Live environment, but when I run

grub-install --efi-directory=/run/archiso/bootmnt

if I use "/run/archiso/bootmnt", it tries to write the /run/archiso/bootmnt/EFI/ folder but since /run/archiso is a read-only directory, it cannot write there so the command fails.

Offline

#5 2023-07-20 00:19:01

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,605

Re: [SOLVED] Missing GRUB not able to reinstall it

That is NOT your 'efi-directory'. You point it to where you mounted the ESP on the internal drive.

Offline

#6 2023-07-20 14:12:58

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 186

Re: [SOLVED] Missing GRUB not able to reinstall it

@Scimmia sorry, you're right. I read the proposal of @Ferdinand too late night. So yes, I mounted what I needed and I run the grub commands with no arch-chroot. So I did:

sudo pacman -S arch-install-scripts
sudo mount -o subvol=@ /dev/sda3 /mnt
sudo mount -o subvol=@home /dev/sda3 /mnt/home
sudo mount -o subvol=@log /dev/sda3 /mnt/var/log
sudo mount /dev/nvme0n1p1 /mnt/boot
sudo grub-install --efi-directory=/mnt/boot --boot-directory=/mnt/boot

and I get:

Installing for x86_64-efi platform.
Installation finished. No error reported.

But when I run "sudo grub-mkconfig -o /mnt/boot/grub/grub.cfg", I get the error:

/usr/bin/grub-probe: error: failed to get canonical path of `airootfs'.

So, at this point only for "grub-mkconfig" command I ran "arch-chroot /mnt /bin/bash" and inside there I ran:

grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found background: /usr/share/backgrounds/default/grub.png
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.
Adding boot menu entry for UEFI Firmware Settings ...
Detecting snapshots ...
Kernels not found.
If you think an error has occurred, please file a bug report at "https://github.com/Antynea/grub-btrfs"
Unmount /tmp/grub-btrfs.3LXdvIxbdY .. Success
done

fatal library error, lookup self

I don't understand the last row...

Furthermore, on the output it says "Kernels not found" but on that chroot environment "linux-zen" (and its headers) is installed as package.

Last edited by D3vil0p3r (2023-07-20 14:20:40)

Offline

#7 2023-07-20 14:24:56

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,809

Re: [SOLVED] Missing GRUB not able to reinstall it

That suggests you are masking your actual /boot with the ESP mount.

In the chroot, unmount /boot and mount your ESP to /efi or so and then check whether you have kernels in /boot.

Last edited by V1del (2023-07-20 14:27:02)

Offline

#8 2023-07-20 14:30:02

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 186

Re: [SOLVED] Missing GRUB not able to reinstall it

Hey @V1del I tried also that option by chrooting there:

sudo pacman -S arch-install-scripts
sudo mount -o subvol=@ /dev/sda3 /mnt
sudo mount -o subvol=@home /dev/sda3 /mnt/home
sudo mount -o subvol=@log /dev/sda3 /mnt/var/log
sudo mount /dev/nvme0n1p1 /mnt/boot

sudo arch-chroot /mnt

grub-install --efi-directory=/boot

Installing for x86_64-efi platform.
Installation finished. No error reported.
fatal library error, lookup self

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

Generating grub configuration file ...
Found background: /usr/share/backgrounds/default/grub.png
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.
Adding boot menu entry for UEFI Firmware Settings ...
Detecting snapshots ...
Kernels not found.
If you think an error has occurred, please file a bug report at "https://github.com/Antynea/grub-btrfs"
Unmount /tmp/grub-btrfs.BGeOHLO4CI .. Success
done
fatal library error, lookup self

and I still get "Kernels not found." in the last output Could it be a problem related to BTRFS? Because that string seems to be printed by https://github.com/Antynea/grub-btrfs/b … hots-btrfs

Last edited by D3vil0p3r (2023-07-20 14:34:18)

Offline

#9 2023-07-20 14:44:36

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 186

Re: [SOLVED] Missing GRUB not able to reinstall it

An additional update. I noted that, despite on the mounted /dev/sda3 I had installed the linux-zen kernel, its /boot folder didn't contain "initramfs-linux-fallback.img  initramfs-linux.img  intel-ucode.img  vmlinuz-linux" files. So, I fixed it by reinstalling linux-zen and linux-zen-headers, then, when I run "grub-mkconfig -o /boot/grub/grub.cfg", I got:

Generating grub configuration file ...
Found background: /usr/share/backgrounds/default/grub.png
Found linux image: /boot/vmlinuz-linux-zen
Found initrd image: /boot/initramfs-linux-zen.img
Found fallback initrd image(s) in /boot:  initramfs-linux-zen-fallback.img
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.
Adding boot menu entry for UEFI Firmware Settings ...
Detecting snapshots ...
Unmount /tmp/grub-btrfs.LDWJISaWJS .. Success
done
fatal library error, lookup self

I check if the grub has been restored. I keep you informed. I am taking this link as reference: https://github.com/debnath-d/debnath-d. … s/BTRFS.md

Last edited by D3vil0p3r (2023-07-20 14:46:41)

Offline

#10 2023-07-20 15:42:36

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,809

Re: [SOLVED] Missing GRUB not able to reinstall it

See my edit. I'm thinking you never originally mounted your ESP to /boot

Offline

#11 2023-07-20 16:25:01

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 186

Re: [SOLVED] Missing GRUB not able to reinstall it

When I just mount /dev/sda3, the mounted /boot contains:

drwxr-xr-x root root   0 B  Mon Jul 10 17:14:07 2023 efi
drwxr-xr-x root root 112 B  Thu Jul 20 15:43:34 2023 grub
.rw------- root root  55 MB Thu Jul 20 15:43:20 2023 initramfs-linux-zen-fallback.img
.rw------- root root  13 MB Thu Jul 20 15:43:08 2023 initramfs-linux-zen.img
.rw-r--r-- root root  13 MB Thu Jul 20 15:43:05 2023 vmlinuz-linux-zen

where "efi" folder is empty.

/dev/nvme0n1p1 (that is the ESP) contains:

drwxr-xr-x root root 4.0 KB Tue Jul 18 17:46:50 2023 EFI
drwxr-xr-x root root 4.0 KB Thu Jul 20 14:42:26 2023 grub
.rwxr-xr-x root root  55 MB Thu Jul 20 14:41:36 2023 initramfs-linux-zen-fallback.img
.rwxr-xr-x root root  13 MB Thu Jul 20 14:41:28 2023 initramfs-linux-zen.img
drwxr-xr-x root root 4.0 KB Fri Dec  2 00:43:18 2022 System Volume Information
.rwxr-xr-x root root  13 MB Thu Jul 20 14:41:24 2023 vmlinuz-linux-zen

So I guess to map only the EFI folder of /dev/nvme0n1p1 to /boot/efi/ folder of /dev/sda3 I guess, by

mkdir /tmp/intermediate
sudo mount /dev/nvme0n1p1 /tmp/intermediate
sudo mount --bind /tmp/intermediate/EFI /mnt/boot/efi/

sudo arch-chroot /mnt
grub-install --efi-directory=/boot/efi
grub-mkconfig -o /boot/grub/grub.cfg

It should be compliant with your statement (I hope)

Offline

Board footer

Powered by FluxBB