You are not logged in.

#1 2023-05-16 07:47:40

an4s911
Member
Registered: 2021-12-04
Posts: 9

[SOLVED] grub-install fails on chrooted btrfs system

I have a btrfs system with a separate home partition which is also btrfs.

I had an update on Windows and it basically removed grub and turned on Secure Boot which didn’t allow me to get into the USB arch iso. But now I got into the live usb, and I tried mounting the partitions, chrooting into it, and then trying to re-install grub using "grub-install" but it gives me an error.

I mounted the root partition, the home partition and the efi partition into their respective directories and then chrooted into the '@' subvolume in the root partition:

mount /dev/nvme0n1p5 /mnt
mount /dev/nvme0n1p7 /mnt/@/home
mount /dev/nvme0n1p4 /mnt/@/boot/efi
arch-chroot /mnt/@

and then I ran the command:

grub-install —targer=x86_64-efi —efi-directory=/boot/efi —bootloader-id=archlinux-2 —recheck

and it gives me this error:

grub-install: error: cannot find a device for /boot/grub (is /dev mounted?).

Also note that when I chroot into `/mnt/@` it gives me this warning:

==> WARNING: @ is not a mountpoint. This may have undesirable side effects.

[SOLVED]:

Head_on_a_Stick wrote:

You can just re-create the GRUB boot entry from the live environment, for example:

# efibootmgr --create --disk /dev/nvme0n1 --part 4 --label 'Arch' --loader '/EFI/archlinux-2/grubx64.efi'

No need to mess around with a chroot or re-run grub-install.

Last edited by an4s911 (2023-05-16 09:31:54)

Offline

#2 2023-05-16 08:10:15

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] grub-install fails on chrooted btrfs system

an4s911 wrote:

I had an update on Windows and it basically removed grub

Did it actually remove the GRUB boot entry or did it just place the Windows entry above it in the boot order?

Please share the output of

efibootmgr -u

If the GRUB entry is still there use efibootmgr's -o option to fix things.

an4s911 wrote:

I mounted the root partition to `/mnt` and then mount the home partition to "/mnt/@/home", and then I mounted the EFI parition to "/mnt/@/boot/efi" and then chrooted into "/mnt/@"

You should post the actual commands rather than vague descriptions.

an4s911 wrote:

and it gives me this error:

grub-install: error: cannot find a device for /boot/grub (is /dev mounted?).

Either (bind) mount the API filesystems before using chroot or use arch-chroot(8) instead, which will mount /dev/ automagically.

an4s911 wrote:

Also note that when I chroot into `/mnt/@` it gives me this warning:

==> WARNING: @ is not a mountpoint. This may have undesirable side effects.

Once again, please share the exact command used to mount the root subvolume. Looks like you did it wrong.

EDIT: so you need something like

# mount -o subvol=@ /dev/sdXY /mnt
# arch-chroot /mnt

How did you install Arch originally?

Last edited by Head_on_a_Stick (2023-05-16 08:25:13)


Jin, Jîyan, Azadî

Offline

#3 2023-05-16 08:35:19

an4s911
Member
Registered: 2021-12-04
Posts: 9

Re: [SOLVED] grub-install fails on chrooted btrfs system

Head_on_a_Stick wrote:
an4s911 wrote:

I had an update on Windows and it basically removed grub

Did it actually remove the GRUB boot entry or did it just place the Windows entry above it in the boot order?

As I understand, it actually removed GRUB, because I can't find the option in the boot menu.

Head_on_a_Stick wrote:

Please share the output of

efibootmgr -u

If the GRUB entry is still there use efibootmgr's -o option to fix things.

I can add it here. Currently I am on windows, so I will reboot into the live usb and check the output and then come back here and add

Head_on_a_Stick wrote:
an4s911 wrote:

I mounted the root partition to `/mnt` and then mount the home partition to "/mnt/@/home", and then I mounted the EFI parition to "/mnt/@/boot/efi" and then chrooted into "/mnt/@"

You should post the actual commands rather than vague descriptions.

mount /dev/nvme0n1p5 /mnt
mount /dev/nvme0n1p7 /mnt/@/home
mount /dev/nvme0n1p4 /mnt/@/boot/efi
arch-chroot /mnt/@

I apologize, I should have added these commands.

Head_on_a_Stick wrote:
an4s911 wrote:

and it gives me this error:

grub-install: error: cannot find a device for /boot/grub (is /dev mounted?).

Either (bind) mount the API filesystems before using chroot or use arch-chroot(8) instead, which will mount /dev/ automagically.

I don't know what you mean by that. How do I (bind) mount the API filesystems. As included in the commands above, I did use "arch-chroot", but seems like it didn't mount /dev/.

Head_on_a_Stick wrote:

EDIT: so you need something like

# mount -o subvol=@ /dev/sdXY /mnt
# arch-chroot /mnt

Ok, I will try that and report back. Thank you.

Last edited by an4s911 (2023-05-16 08:35:42)

Offline

#4 2023-05-16 09:08:50

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] grub-install fails on chrooted btrfs system

You can just re-create the GRUB boot entry from the live environment, for example:

# efibootmgr --create --disk /dev/nvme0n1 --part 4 --label 'Arch' --loader '/EFI/archlinux-2/grubx64.efi'

No need to mess around with a chroot or re-run grub-install.

EDIT: or from Windows:

bcdedit /set "{bootmgr}" path "\EFI\archlinux-2\grubx64.efi"

Last edited by Head_on_a_Stick (2023-05-16 09:11:32)


Jin, Jîyan, Azadî

Offline

#5 2023-05-16 09:11:07

an4s911
Member
Registered: 2021-12-04
Posts: 9

Re: [SOLVED] grub-install fails on chrooted btrfs system

I can do that?

The —disk part needs to be the efi parition or the whole disk? Because there are two efi partitions in the disk, one for Windows and one for Linux.

Offline

#6 2023-05-16 09:11:56

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] grub-install fails on chrooted btrfs system

Read the manpage. You should do that anyway for any new command. EDIT: the Linux ESP is what you need (ie, the partition to be mounted under /boot/efi/ in the installed system).

Last edited by Head_on_a_Stick (2023-05-16 09:12:46)


Jin, Jîyan, Azadî

Offline

#7 2023-05-16 09:13:09

an4s911
Member
Registered: 2021-12-04
Posts: 9

Re: [SOLVED] grub-install fails on chrooted btrfs system

Head_on_a_Stick wrote:

EDIT: or from Windows:

bcdedit /set "{bootmgr}" path "\EFI\archlinux-2\grubx64.efi"

I tried that tho. But didn’t work

Offline

#8 2023-05-16 09:16:21

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] grub-install fails on chrooted btrfs system

That command would only work if grubx64.efi was on the Windows ESP. You'll have to use efibootmgr instead. I'm sure it's doable from Windows but I don't know how (sorry).

Last edited by Head_on_a_Stick (2023-05-16 09:16:57)


Jin, Jîyan, Azadî

Offline

#9 2023-05-16 09:30:49

an4s911
Member
Registered: 2021-12-04
Posts: 9

Re: [SOLVED] grub-install fails on chrooted btrfs system

Head_on_a_Stick wrote:

You can just re-create the GRUB boot entry from the live environment, for example:

# efibootmgr --create --disk /dev/nvme0n1 --part 4 --label 'Arch' --loader '/EFI/archlinux-2/grubx64.efi'

No need to mess around with a chroot or re-run grub-install.

This worked. Thank you so much.

Offline

Board footer

Powered by FluxBB