Broke my bootloader grub, need help fixing it(SOLVED)

I installed a package in Linux that let me edit some options in grub, for example change the boot order. When I applied these changes it somehow broke grub and now I just get to the command line) . Of course I should be able to restore grub and get it like it was before via the command line? I have googled and searched and found commands but no command seem to work, they are all unknown. I also downloaded and made a bootable USB with super grub disc but that does not work either.

What package did you install?

best thing to do. Boot up that USB. open a console.

list your partitions fdisk -l
assuming its a standard install you'll have at least 2 partitions, a root partition and boot partition. they will be listed something like /dev/sda1 /dev/sda2 etc.

Figure out whats what. the OS partition is usually the largest, the boot partition is usually the smallest (but not EFI if thats listed too). For this example ill use sda2 as / and sda1 as /boot

mount your root (OS) partition and boot partition then chroot into them

mount /dev/sda2 /mnt
mount /dev/sda1 /mnt/boot
chroot /mnt

Backup and then Then fix grub

cp /boot/grub/grub.cfg /boot/grub/grub.cfg.backup
grub2-mkconfig -o > /boot/grub/grub.cfg

unload and reboot

umount /mnt/boot
umount /mnt

Keep in mind.

You've not given us much info. Your OS might have grub1-mkconfig as grub-mkconfig. You haven't said what the program was or what it changed. If it changed /etc/default/grub then this wont work, you'll need to edit /etc/default/grub back to its normal settings and run the grub2-mkconfig command as above again.

Here is an example output of fdisk. You can see you can make assumptions from the sizes. EFI is the EFI partition, 500M is very small its the boot partition, 457G is obviously the main root partition, and 7.3G is the swap (the same amount as my ram)

[[email protected] eden]# fdisk -l

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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
Disklabel type: gpt
Disk identifier: EE69EE85-9C91-4B46-BB0D-6EF0F7C5388E

Device         Start       End   Sectors   Size Type
/dev/sda1       2048    411647    409600   200M EFI System
/dev/sda2     411648   1435647   1024000   500M Linux filesystem
/dev/sda3    1435648 961564671 960129024 457.8G Linux filesystem
/dev/sda4  961564672 976769023  15204352   7.3G Linux filesystem

Disk /dev/sdb: 111.8 GiB, 120034123776 bytes, 234441648 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
Disklabel type: dos
Disk identifier: 0x0aefedb6

Yes I\m sorry, I\m in a bit of hurry, I\m writing this from a live usb and my keyboard settings are all wrong to, making it very tideous to type in commands, I will try this and report back. The package I used was grub-customizer,

First I changed the boot order, and that worked fine. Then I rebooted and changed the timeout for grub to boot by itself. When I changed it from 10 second to 3 this happend.


On the live USB I installed the same package and restored settings, seem to have solved the problem. A big thanks anyways! Worried I'd had to reformat my harddrive.