You are not logged in.
Hi,
I dual boot Windows 10 and Arch Linux. For some reason, windows has been overwriting GRUB lately, so that when I start the laptop, Windows simply boots as if GRUB was never installed.
This is weird, but ultimately it's simply a matter of reinstalling GRUB, not a huge deal. However, when I do so, it all succeeds fine, but when I reboot, Windows boots as if I hadn't done anything. There are no errors at any time.
Here are the steps I'm following. I've done this 3 times already and carefully checked the commands. Does anyone have any idea what might be going wrong?
I reboot into the rescue media USB stick.
I mount the Linux partition to /mnt:
sudo mount /dev/nvme0n1p4 /mnt
I mount the EFI partition to /mnt/boot/efi (this directory is empty before I mount anything)
sudo mount /dev/nvme0n1p1 /mnt/boot/efi
Then:
arch-chroot /mnt
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg
The commands above complete without errors
Then I exit the chroot, unmount the EFI partition and then the root partition and reboot
Windows starts as if I'd done nothing.
EDIT: I'm definitely booting everything in UEFI mode and always have. I did have this working before without issue also.
I assume I'm missing something really silly and obvious.
Last edited by calef13 (2023-02-04 12:13:29)
Offline
What does `efibootmgr -u` show?
Offline
Keep an eye in your BIOS config, in "boot priority" or something like that. I experimented that behavior when "Windows Boot Manager" boot first in priority and not Arch Linux the first one. Put Arch first in priority in your motherboard config.
Offline
`efibootmgr -u` shows:
# efibootmgr -u
BootCurrent: 0012
Timeout: 0 seconds
BootOrder: 0001,0003,0006,000D,000E,0010,0012
Boot0000 ubuntu HD(1,GPT,7887b2c4-6eaa-4a82-b8d6-493012efed73,0x800,0xfa000)/File(\EFI\ubuntu\shimx64.efi)
Boot0001* GRUB HD(1,GPT,2dc13b26-dd2c-4745-ae08-6a8394f449ae,0x800,0xfa000)/File(\EFI\GRUB\grubx64.efi)
Boot0002* Windows Boot Manager HD(1,GPT,7887b2c4-6eaa-4a82-b8d6-493012efed73,0x800,0xfa000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)䥗䑎坏S
Boot0003* Diskette Drive BBS(Floppy,Diskette Drive,0x0)
Boot0006* CD/DVD/CD-RW Drive BBS(CDROM,CD/DVD/CD-RW Drive,0x0)
Boot000B* Diskette Drive BBS(Floppy,Diskette Drive,0x0)
Boot000D* USB Storage Device BBS(USB, USB DISK 1100,0x0)
Boot000E* M.2 PCIe SSD BBS(HD,THNSN5512GPU7 NVMe TOSHIBA 512G,0x0)
Boot0010* UEFI: THNSN5512GPU7 NVMe TOSHIBA 512GB, Partition 1 HD(1,GPT,7887b2c4-6eaa-4a82-b8d6-493012efed73,0x800,0xfa000)/File(EFI\Microsoft\Boot\bootmgfw.efi)
Boot0012* UEFI: USB DISK 1100, Partition 1 PciRoot(0x0)/Pci(0x14,0x0)/USB(0,0)/HD(1,GPT,2dc13b26-dd2c-4745-ae08-6a8394f449ae,0x800,0x77ffdf)
Boot0014* UEFI: Generic Flash Disk 8.07, Partition 1 PciRoot(0x0)/Pci(0x14,0x0)/USB(1,0)/HD(1,MBR,0x5f20069e,0xb4,0x20000)
Ignore the ubuntu entry, that's an old unused relic. Happy to hear tips on removing it.
Looks like Arch is the first priority? But then windows doesn't even appear in the priority list. Or maybe I'm reading it wrong?
Offline
I should mention I accidentally ran the GRUB installation in BIOS mode when I was trying to reinstall it. So this might have messed things up further. But it doesn't seem to have caused any issues. Windows does still boot fine. But GRUB just never appears at all.
Offline
# efibootmgr -u Boot0000 ubuntu HD(1,GPT,7887b2c4-6eaa-4a82-b8d6-493012efed73,0x800,0xfa000)/File(\EFI\ubuntu\shimx64.efi) Boot0001* GRUB HD(1,GPT,2dc13b26-dd2c-4745-ae08-6a8394f449ae,0x800,0xfa000)/File(\EFI\GRUB\grubx64.efi) Boot0002* Windows Boot Manager HD(1,GPT,7887b2c4-6eaa-4a82-b8d6-493012efed73,0x800,0xfa000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)䥗䑎坏S
Ignore the ubuntu entry, that's an old unused relic. Happy to hear tips on removing it.
Do you have two ESP(s)?
Also:
-b | --bootnum XXXX Modify BootXXXX (hex) -B | --delete-bootnum Delete bootnum (hex)
<49,17,III,I> Fama di loro il mondo esser non lassa;
<50,17,III,I> misericordia e giustizia li sdegna:
<51,17,III,I> non ragioniam di lor, ma guarda e passa.
Offline
Is secure boot enabled? Seeing as buuntu is a shim, that could be the limiting factor here.
Offline
Pretty sure I've disabled secure boot. I think that's a requirement for dual booting? And I had dual booting working without issue for years on this laptop before.
I only have one ESP. I was booting using this ESP partition before. As I said, it was somehow overwritten twice already. I'm assuming Windows 10 did it somehow, but I'm honestly completely unsure how it happened. I'll try deleting some of the UEFI boot entries using -b and see if that helps.
Isn't there a way to get some kind of debug log from GRUB? It's invoked first according to the boot order, can't I see how that happens?
Offline
you installed grub to /boot/efi
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
but your nvram entry points to the efi partition
Boot0001* GRUB HD(1,GPT,2dc13b26-dd2c-4745-ae08-6a8394f449ae,0x800,0xfa000)/File(\EFI\GRUB\grubx64.efi)
you can install your grub bootloader to the efi partition with:
# grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB
# grub-mkconfig -o /boot/grub/grub.cfg
and leave the nvram entry as is or you can point the nvram entry to the location where grub is installed right now:
# efibootmgr --unicode --disk /path/to/disk --create --label "GRUB" --loader /path/to/grubx64.efi
Offline
For clarity, here is my `fdisk -l` output:
$ sudo fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: THNSN5512GPU7 NVMe TOSHIBA 512GB
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: 0D6EB30B-E93A-45A1-8730-251E389FBCB3
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 1026047 1024000 500M EFI System
/dev/nvme0n1p2 1026048 7317503 6291456 3G Microsoft basic data
/dev/nvme0n1p3 7317504 7727103 409600 200M Linux filesystem
/dev/nvme0n1p4 7727104 41519103 33792000 16.1G Linux swap
/dev/nvme0n1p5 839247872 839280639 32768 16M Microsoft reserved
/dev/nvme0n1p6 839280640 999137728 159857089 76.2G Microsoft basic data
/dev/nvme0n1p7 999139328 1000212479 1073152 524M Windows recovery environment
/dev/nvme0n1p8 41519104 717359103 675840000 322.3G Linux filesystem
/dev/nvme0n1p9 717359104 839247871 121888768 58.1G Microsoft basic data
Partition table entries are not in disk order.
Here is my fstab:
$ cat /mnt/etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=4467-8AFA /boot/efi vfat defaults,noatime 0 2
UUID=e922cefe-9d51-4500-bb4d-3eb6b711b75a swap swap defaults 0 0
UUID=21dd6eaf-83af-482d-8671-f6c48bfd12d3 / ext4 defaults,noatime 0 1
No EFI directory exists when I `ls /`. I think the efibootmgr output says /EFI and means the root of the EFI system partition, which I mount under /boot in my root partition.
Offline
I notice in the efibootmgr output, the 0010 entry is prefixed with `UEFI:`, however the GRUB one is not. Is that at all significant?
Offline
When I am selecting the boot device in the BIOS, I see GRUB as an option alongside my USB stick, but if I select it, it just starts the disk troubleshooting application. So it seems broken. But that is a new entry at least.
Offline
When I try to run `sudo efibootmgr -B 0000` or `sudo efibootmgr -B ubuntu` I get the error `You must specify an entry to delete (see the -b option or -L option).` I'm not sure what I'm doing wrong here.
From looking at the efibootmgr output, it feels like GRUB installed, but on boot it fails somehow, and the system then simply moves onto Windows instead. I'm unsure how to debug GRUB failing to start though, I've never had that happen. Does anyone have any ideas?
Offline
To delete an entry use
# efibootmgr -b xxxx -B
This is shown in the EXAMPLES section of efibootmgr(8). Any reason why you didn't bother reading it?
As for this:
Boot0001* GRUB HD(1,GPT,2dc13b26-dd2c-4745-ae08-6a8394f449ae,0x800,0xfa000)/File(\EFI\GRUB\grubx64.efi)
The PARTUUID (2dc13b26-dd2c-4745-ae08-6a8394f449ae) does not match the other, working, entries so it looks like you directed grub-install to the wrong partition.
Some UEFI firmware implementations can behave very strangely so perhaps yours is refusing to update the old, incorrect "GRUB" entry when you run grub-install again with the correct ESP mountpoint specified.
Does this help:
# efibootmgr -b 1 -B
# mount /dev/nvme0n1p1 /boot/efi
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
Check efibootmgr again after running those commands to make sure the PARTUUID for the "GRUB" entry matches the Windows entry.
Last edited by Head_on_a_Stick (2023-02-03 07:04:19)
Para todos todo, para nosotros nada
Offline
Here is my fstab:
UUID=4467-8AFA /boot/efi vfat defaults,noatime 0 2 UUID=e922cefe-9d51-4500-bb4d-3eb6b711b75a swap swap defaults 0 0 UUID=21dd6eaf-83af-482d-8671-f6c48bfd12d3 / ext4 defaults,noatime 0 1
Your fstab is wrong - you can't mount /boot/efi before / is mounted
Offline
/ is mounted in the initramfs, so that doesn't really matter.
Offline
To delete an entry use
# efibootmgr -b xxxx -B
This is shown in the EXAMPLES section of efibootmgr(8). Any reason why you didn't bother reading it?
As for this:
calef13 wrote:Boot0001* GRUB HD(1,GPT,2dc13b26-dd2c-4745-ae08-6a8394f449ae,0x800,0xfa000)/File(\EFI\GRUB\grubx64.efi)
The PARTUUID (2dc13b26-dd2c-4745-ae08-6a8394f449ae) does not match the other, working, entries so it looks like you directed grub-install to the wrong partition.
Some UEFI firmware implementations can behave very strangely so perhaps yours is refusing to update the old, incorrect "GRUB" entry when you run grub-install again with the correct ESP mountpoint specified.
Does this help:
# efibootmgr -b 1 -B # mount /dev/nvme0n1p1 /boot/efi # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
Check efibootmgr again after running those commands to make sure the PARTUUID for the "GRUB" entry matches the Windows entry.
I did bother reading the manpages actually(assumptions are dangerous!), both in the shell and online, and I looked for examples there, but I somehow missed it. But thanks for pointing it out. I got confused by this syntax, but it makes sense now.
The PARTUUID tip fixed it, so thanks a million, really! This UUID is from the USB stick I was using. Somehow, the entry was being overwritten. Initially it's correct, but when I reboot it wouldn't work, and when I'd boot back up it would be the wrong PARTUUID. Real strange.
I was only running grub-install and grub-mkconfig from inside arch-chroot, so that doesn't explain the overwriting either.
I was using EndeavourOS, and that's what the USB rescue stick was(I've since got fed up with this distro and I'm reverting back to my old Arch setup). So I made an arch linux rescue one and then reinstalled GRUB and it worked. Still not sure what exactly was going wrong, but it seems to have been related to the EndeavourOS. I've had nothing but bugs with this distro sadly, and I wish I'd know about the archinstall method before hahaha.
Thanks to everyone for the help. I think I now know enough about efibootmgr to sort any future issues too so thanks for the education!
Offline