On my computer I have Ubuntu 19.04 intalled along with Windows 10 and Fedora 29.
In Ubuntu, running sudo update-grub
gives the following:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-13-generic
Found initrd image: /boot/initrd.img-5.0.0-13-generic
Found linux image: /boot/vmlinuz-4.18.0-18-generic
Found initrd image: /boot/initrd.img-4.18.0-18-generic
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Fedora 29 (Workstation Edition) on /dev/mapper/fedora-root
Adding boot menu entry for EFI firmware configuration
done
which I think looks fine, it detects both Windows Boot Manager and Fedora 29 and it sets up a grub menu letting me choose between the different operating systems at boot time.
My problem is that Fedora needs some special configuration in order to workaround some graphics driver problems. Specifically, the options rd.driver.blacklist=nouveau modprobe.blacklist=nouveau
need to be added for that grub menu entry.
I am able to fix this by manually editing the file /boot/grub/grub.cfg
but that change is overwritten next time update-grub
runs, so it is not a good solution. Also, the file /boot/grub/grub.cfg
that I am then editing starts with a comment saying "DO NOT EDIT THIS FILE", also indicating that I should perhaps not edit it.
My question is: how can I add some extra boot options for the Fedora grub entry that is generated when I run sudo update-grub
in Ubuntu?
There are some options in the /etc/default/grub
file that is used by update-grub
, for example I can choose GRUB_TIMEOUT there which works fine, but as far as I know that file does not allow me to specify boot options for other operating systems, only for Ubuntu itself.
To further clarify what I mean, the auto-generated /boot/grub/grub.cfg
file (created by update-grub
) contains a section looking like this, specifying how Fedora is booted if that grub menu option is chosen:
menuentry 'Fedora 29 (Workstation Edition) (on /dev/mapper/fedora-root)' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-6398dc3c-28e3-4947-ad82-d9defe5d9a28' {
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root b00e70c6-820f-4615-b95d-c933eaea0d3f
else
search --no-floppy --fs-uuid --set=root b00e70c6-820f-4615-b95d-c933eaea0d3f
fi
linux /vmlinuz-5.0.9-200.fc29.x86_64 root=/dev/dm-2
initrd /initramfs-5.0.9-200.fc29.x86_64.img
}
and I would like the above to look slightly different, adding the options rd.driver.blacklist=nouveau modprobe.blacklist=nouveau
in the end of the line starting with linux
. Is there some way to tell update-grub
to do that?
I did see the suggestion here about editing the /etc/grub.d/40_custom
file but that solution means writing the whole menuentry manually so it will not adapt when the kernel version in Fedora changes. The auto-generated menuentry created by update-grub
has the advantage that it gives the latest Fedora kernel, I would like to use that and just add something to the "linux" line inside the auto-generated menuentry. Can that be done, and if so, how?
Here is my inelegant solution.
Open
/etc/grub.d/30_os-prober
to edit.Find the line where
LPARAMS
is defined and change its value to whatever you want appended at the end of the linux line in the grub menu entry. Include all desired parameters (including the root value), with appropriate spacing. As a precaution, leave the original LPARAMS line, but commented out.Run update-grub.
This process will append your additions as parameters for every linux os that is probed for.
There is surely a more specific way to do this by adding custom logic to
/etc/grub.d/30_os-prober
, but I do not know how.