Make changes/additions to /boot/grub/grub.cfg permanent?

Hi,
is it possible to permanently add some option in “grub.cfg” to the “linux” command line?
I noticed that changes there are overwritten by core updates. So is there something like a “local override” mechanism or any othe way that I can make additions permanent?
TIA!

You need to make changes in:

  • /etc/grub/10_linux
  • /etc/default/grub

Such changes will be incorporated in grub.cfg next time there is a kernel upgrade in a core update.

1 Like

Thanks, and these files are not overwritten by an update?

I think they probably will, but I am not 100% sure. Another way would be to add grub.cfg to /var/ipfire/backup/include.user and restore your config after the update. See the wiki entry for the backup system.

EDIT: this is an embarrassingly stupid idea, as described by @bonnietwin in a post #5 to this thread.

1 Like

These will be overwritten if grub is updated in a core update as those files are part of the grub rootfile set.

You would need to be careful with this. grub.cfg is a file that is created anew by grub-mkconfig every time a kernel update is done. I am not sure what might happen if you copied back a grub.cfg from an earlier version of IPFire into one with a new kernel.
Even if it does work then doing this will mean that any improvements, changes done to the grub system will never be available on your system as the restore will replace the grub.cfg with an older based version.

Your best bet would be to add your option into /etc/default/grub after any core update, if it is needed, and run
grub-mkconfig -o /boot/grub/grub.cfg
and reboot.

You could probably create a script that you would run after a core update has been done that checks if your option is still present or not and runs the grub-mkconfig command if needed.

5 Likes

What is your opinion on writing a script called by rc.local at boot time that checks /etc/default/grub for the presence of those modifications, if absent it adds them, then it calls grub-mkconfig and then reboot?

Do you see any problem with this approach?

1 Like

That would seem a reasonable approach to me and would be what I would try out if I needed it.
I can’t see any problems with it but I am just a hobbyist in computing so I could be wrong.
It would be good if other more experienced people could confirm this approach as being the best way.

3 Likes

/etc/default/grub will not overwritten because it is excluded to prevent this. (It contain the config if serial consoles are used or not.)
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=config/rootfiles/core/174/exclude;h=378c2d5632fcb78995d2639006b965e3a9ef2088;hb=11f4726b0d72b6a4a0799bb4548e9ce93bf16911

4 Likes

That’s good to know. That makes the situation for @chrisk1 much easier. :+1:

2 Likes