Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] Destroyed my GRUB setup (Read 2414 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] Destroyed my GRUB setup

Well this is embarassing...

I installed the packages linux-zen and linux-zen-headers using sudo pacman -S <packages>. After that I ran sudo update-grub but me being a big dummy didnt run mkconfig. Now when I boot I do so but directly to the bios. Currently using a live usb, and I can chroot using artix-chroot, but I'm not exactly sure what to do now. It's an UEFI system, and I'll post any logs needed to help fix this.

If I can get help with this, it would be very appreciated!

Re: Destroyed my GRUB setup

Reply #1
I will post some logs I managed to get>
lsblk
NAME  MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0   7:0    0  73.3M  1 loop /run/artix/sfs/livefs
loop1   7:1    0   1.1G  1 loop /run/artix/sfs/rootfs
sda     8:0    1    59G  0 disk
├─sda1
│       8:1    1   1.2G  0 part /run/artix/bootmnt
└─sda2
        8:2    1     4M  0 part
nvme0n1
      259:0    0 953.9G  0 disk
├─nvme0n1p1
│     259:1    0   300M  0 part
├─nvme0n1p2
│     259:2    0 919.7G  0 part /run/media/artix/c8536395-6f76-4dab-a7a5-745aaa596c28
└─nvme0n1p3
      259:3    0  33.8G  0 part [SWAP]

The nvme0n1p1 partition would be the boot partition.

Re: Destroyed my GRUB setup

Reply #2
Once you have chrooted into the system, re-install grub and you should be good to go.
The following is should work for you if your ESP partition is /boot/efi.
The bootloader ID should be the same as what your current Grub name, otherwise you will have a new entry into the system's UEFI boot menu through efibootmgr and remove the old broken entry.
Code: [Select]
#efibootmgr
BootCurrent: 0000
Timeout: 1 seconds
BootOrder: 0000
Boot0000* Grub HD(<Number>,GPT,<Partition GUID>,0x800,0x100000)/File(\EFI\GRUB\GRUBX64.EFI)
This is show you the current UEFI boot menu list. Look for a line that contains \EFI\GRUB\GRUBX64.EFI. The bootloader ID is the name after Boot0000* which in this case would be "Grub".
Code: [Select]
#grub-install --target=x86_64-efi --efi=/boot/efi --bootloader-id=<GRUB name from efibootmgr list>
#grub-mkconfig -o /boot/grub/grub.cfg

I would recommend creating a script with the grub install line for the next time and place in /usr/local/bin/efi-grub-install.sh should you require it again in the future without the hassle of figuring out the correct syntax again.

Re: Destroyed my GRUB setup

Reply #3
The results of running the first command are
BootCurrent: 0007
Timeout: 1 seconds
BootOrder: 0007,0008,0006,0001,0000
Boot0000* Windows Boot Manager   VenHw(99e275e7-75a0-4b37-a2e6-c5385e6c00cb)57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d00000000000100000010000000040000007fff0400
Boot0001* grub   VenHw(99e275e7-75a0-4b37-a2e6-c5385e6c00cb)
Boot0006* UEFI OS   HD(1,GPT,eafbd316-af50-ba45-a13a-afc5b222e99c,0x1000,0x96000)/File(\EFI\BOOT\BOOTX64.EFI)0000424f
Boot0007* UEFI: USB   PciRoot(0x0)/Pci(0x8,0x1)/Pci(0x0,0x4)/USB(5,0)/CDROM(1,0x26c8e4,0x8000)0000424f
Boot0008* UEFI: USB, Partition 2   PciRoot(0x0)/Pci(0x8,0x1)/Pci(0x0,0x4)/USB(5,0)/HD(2,MBR,0x0,0x26c8e4,0x2000)0000424f

Is the line Im looking for the one starting with Boot0001 or Boot00006?

EDIT I supopse it would be the line starting with Boot0006, right?
EDIT 2 Using UEFI on the grub install gives the error /boot/efi doesn't look like an EFI partition, same if using 'UEFI OS'

Re: Destroyed my GRUB setup

Reply #4
Also, running the mkconfig command gets me this

Generating grub configuration file ...
Found theme: /usr/share/grub/themes/artix/theme.txt
Found linux image: /boot/vmlinuz-linux-zen
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux-zen.img
Found fallback initrd image(s) in /boot:  intel-ucode.img amd-ucode.img initramfs-linux-zen-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot:  intel-ucode.img amd-ucode.img initramfs-linux-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.
ERROR: mkdir /var/lock/dmraid
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done

Re: Destroyed my GRUB setup

Reply #5
The efibootmgr list shows that the bootloader ID is "grub" and the line appears to be broken.
Thus once everything is mounted and you have chrooted into the system.  It is critical that the ESP path is /boot/efi for the example to address your issue if the path is different then please adjust the "--efi=<PATH>" to your installation setup.
Run:
Code: [Select]
#grub-install --target=x86_64-efi --efi=/boot/efi --bootloader-id=grub
That should reconfigure the "Boot0001* grub" correctly. Once the grub line shows the complete path to the EFI file, it will work again.
If it just does not work then one would have to use a new bootloader ID name and then clean up stuff afterwards to set the correct default boot order to the "New bootloader ID" and to remove the broken grub entry. Some motherboards have UEFI issues and may need a hammer and rebuild approach the boot menu.
Also run:
Code: [Select]
 #grub-mkconfig -o /boot/grub/grub.cfg
I always run both after a grub update. That way one should not have any bad surprises on the next boot.

Re: Destroyed my GRUB setup

Reply #6
Lets assume I somehow chrooted wrong the system. What would be the steps to do so properly?

Re: Destroyed my GRUB setup

Reply #7
Your grub-mkconfig -o /boot/grub/grub.cfg output shows that grub is broken.
Code: [Select]
 grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
The error should be addressed once the UEFI boot entry has been corrected or rebuilt and the grub-mkconfig is run again.
Although I do find it puzzling that you have both the Itel and AMD ucodes installed. I would uninstall the ucode that is not correct for the actual CPU that is installed on your system.

Re: Destroyed my GRUB setup

Reply #8
First mount the root partition, then once it is mounted, view the /<mount path>/etc/fstab file and mount the rest of the partitions if any exist. The Artix devs have a script called "artix-chroot" from "artools-base" that will mount the important system folders once the root folder is mounted.
Code: [Select]
#artix-chroot <mount path of system root>
Or one can do it manually like so after root is mounted:
Code: [Select]
# cd /<path of the root mount>
# mount -t proc /proc proc/
# mount -t sysfs /sys sys/
# mount --rbind /dev dev/
# mount --rbind /sys/firmware/efi/efivars sys/firmware/efi/efivars/
# chroot /<path of the root mount>
Then run the grub commands.

Re: Destroyed my GRUB setup

Reply #9
Just to be sure, should I mount the boot or the root partition? I have nvme0n1p1 for the boot an the nvme0n1p2 for root.

Re: Destroyed my GRUB setup

Reply #10
Going back again I'm not sure I understood this line:
It is critical that the ESP path is /boot/efi for the example to address your issue if the path is different then please adjust the "--efi=<PATH>" to your installation setup.

I managed to confirm I'm chrooting fine, even used the artix-chroot tool.

Re: Destroyed my GRUB setup

Reply #11
The mounts for those NVME partitions would be the following with root mounted on /mnt:
Code: [Select]
#mount /dev/nvme0n1p2 /mnt/
#mount /dev/nvme0n1p1 /mnt/boot
#cd /mnt
# mount -t proc /proc proc/
# mount -t sysfs /sys sys/
# mount --rbind /dev dev/
# mount --rbind /sys/firmware/efi/efivars sys/firmware/efi/efivars/
# chroot /mnt
If you have a separate home or any other folders I would recommend mounting them as well before the chroot command. Check the /mnt/etc/fstab file to be sure. You should be able to address the UEFI boot menu issue with GRUB and have a normal working environment again.

Re: Destroyed my GRUB setup

Reply #12
The ESP path is the root of storage devices EFI folder. If one follow the standard Artix installation then the complete path for the GRUB EFI after it is successfully installed would be:
Code: [Select]
#/boot/efi/EFI/GRUB
The root of the storage based part of the EFI would be:
Code: [Select]
 #/boot/efi 
This is the "EFI System Partition (ESP)". This path can be changed on installation though most do not.
The "EFI/GRUB" partitions are the parts that are seen inside the UEFI boot environment.
But in order to address this it is critical to get the right location or nothing will be fixed.

Re: Destroyed my GRUB setup

Reply #13
Just throwing this out there. Rather than having to chroot in, and then mount this and that etc... you may find it easier to create a rEFInd boot USB and then boot from that in the uefi / bios.

All being well you should be able to use that to get into your normal system and then reinstalling grub should be far simpler.
(Consider actually installing rEFInd instead of reinstalling grub, imho it's better!)

https://www.rodsbooks.com/refind/getting.html

Re: Destroyed my GRUB setup

Reply #14
Alright, jspaces I followed your steps to the letter and managed to get past the grub install. (grub-install --target=x86_64-efi --efi=/boot/efi --bootloader-id=grub). However, grub mkconfig fails with the same error message as before (no grub drive for dev/sda1). How could I diagnose what is going on?