Update or Installing Grub fails with could not load module part_gpt

I recently did re-install my Windows on another disk (dual boot machine) and tried to update grub to correctly boot up Windows as well. But the grub2-mkconfig -o /etc/default/grub
and also grub2-install commands fail:

insmod: ERROR: could not load module part_gpt: No such file or directory
insmod: ERROR: could not load module btrfs: No such file or directory
/etc/default/grub: line 67: search: command not found
/etc/default/grub: line 71: loadfont: command not found
/etc/default/grub: line 79: terminal_output: command not found
insmod: ERROR: could not load module part_gpt: No such file or directory
insmod: ERROR: could not load module ext2: No such file or directory

I tried with several installed kernels, no luck.

I still can boot the system but I fear with the next kernel update things might get messy.

This is a totally f***ed up command and may have destroyed the ability of grub to function for updates..
No where have I ever seen that output file suggested or used. /etc/default/grub is a configuration file that is read by grub2-mkconfig to properly set options in the output.
The proper command would be sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Check the content of the file /etc/default/grub and if it does not look similar to the below then the file must be repaired before any updates can be performed.

$ cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora_root/root rd.lvm.lv=fedora_root/swap rd.driver.blacklist=nouveau modprobe.blacklist=nouveau"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

Thanks for the answer, I restored the system from backup and re-run it correctly.

1 Like