While I was trying to fix a NVIDIA issue, I foolishly removed the /etc/default/grub file. I read that it is supposed to be regenerated by the post-installation script from the grub2-pc package. However, I cannot reinstall the grub2 packages and I do not know why (why they are unavailable).
sudo dnf reinstall grub2-common.noarch grub2-pc.x86_64 grub2-pc-modules.noarch grub2-tools.x86_64 grub2-tools-minimal.x86_64 grubby.x86_64
Last metadata expiration check: 0:22:32 ago on Sun 16 Oct 2022 03:27:21 PM CEST.
Installed package grub2-common-1:2.06-53.fc36.noarch (from updates) not available.
Installed package grub2-pc-1:2.06-53.fc36.x86_64 (from updates) not available.
Installed package grub2-pc-modules-1:2.06-53.fc36.noarch (from updates) not available.
Installed package grub2-tools-1:2.06-53.fc36.x86_64 (from updates) not available.
Installed package grub2-tools-minimal-1:2.06-53.fc36.x86_64 (from updates) not available.
Package Arch Version Repo Size
grubby x86_64 8.40-67.fc36 updates 34 k
The commands worked, but /etc/default/grub is still missing. It seems that the post-installation script of grub2-pc does not regenerate the file, although this AskUbuntu question suggests that it should.
The file /etc/default/grub is built by anaconda during initial installation and after that there is nothing to recreate it. The file is owned by grub2-tools, but as a ghost file, which means that the the file is not provided by grub2 tools.
Therefore you can copy-paste the copy provided by @grumpey and modify it as needed.
@vekruse You are right, the file is owned by grub2-tools, but rpm -V grub2-tools does not complain if it is not there. Bad luck if you delete it by accident. Grepping anaconda files shows that It is created by
/usr/lib64/python3.10/site-packages/pyanaconda/modules/storage/bootloader/grub2.py where you find the template but there are some “%s” to be filled in.
Well then as it belongs to anaconda, shouldn’t it also be on the installer image and therefore the op could just copy it over to /etc no? Just mount an installation media and browse for the file, it is likely in /usr/lib right?