Dual boot of Linux distros: tweaking grub kernel parameters for the 2nd distro

First post in English, I don’t know if more will follow, but this information was impossible to find anywhere else on the internet so I thought it might be useful to have it as understandable to all as possible 🙂

So, maybe if you find yourself in this situation:

  1. you have your own beloved distribution in some partition(s), and don’t plan to change it in the short term
  2. you want to try another distribution in some other partition(s)
  3. you are keeping the boot loader from the distribution at point 1, ‘cos you might remove the other distribution at some point and don’t want to mess up
  4. the boot loader is grub2
  5. you find out that you need to change kernel parameters in grub for the other distribution (for example, you find out that no splash screen is displayed although it’s supported, and find out that it’s because you need the “splash” parameter in that line and it’s not present)
  6. you don’t want to change /boot/grub/grub.cfg by hand, because your distribution updates it automatically anyway after some updates and anyway you’re scared of doing it and messing up

Things is, although Ubuntu, Debian and probably many others have a /etc/grub.d/30_os-prober script which takes care of finding other OS’s (including other Linux distros) on your computer, and a /etc/default/grub file where you can set up GRUB_CMDLINE_LINUX_DEFAULT variable to put your kernel parameters, these, for some obscure reason, only apply to the beloved distribution and not to your other distribution. So you can change as much as you like in that file, you’ll not get your splash screen at boot in the other distro.

Now, if you want those same parameters of GRUB_CMDLINE_LINUX_DEFAULT to apply to any linux distro, you only need to tell /etc/grub.d/30_os-prober to do so!

Just

  • start editing /etc/grub.d/30_os-prober with your favourite editor (gedit, kate, kwrite, nano, vi, etc… the important is just to have root permissions!)
  • find a line which is exactly linux ${LKERNEL} ${LPARAMS} (don’t know how to search in a file with your favourite editor? use an easier one, you won’t look cooler to anybody by using a complicated program you don’t know how to use! 😛 ). Hint: in my Ubuntu, it’s at line 237.
  • add ${GRUB_CMDLINE_LINUX_DEFAULT} to the end of that line, so that it’ll look exactly like this:
    linux ${LKERNEL} ${LPARAMS} ${GRUB_CMDLINE_LINUX_DEFAULT}
  • save the file and run update-grub (as root of course)

That’s it, now everything should be fine! 🙂

Now, if instead you want different parameters for your two distributions (for some specific vesa or vesafb settings, or because you want one to be “quiet splash” and the other only “splash”, or because you like to try as many things as possible and this post is giving you some good ways of doing so), the solution is as easy as before!

All you need to do is to edit your /etc/default/grub (with your favourite editor and blabla as before), and add a new line with the name of a new variable (might be GRUB_CMDLINE_OTHER_LINUX as well as LOVE_WINDOWS or I_HAVE_A_DREAM, capital letters suggested but not mandatory, just don’t use spaces), a “=”, and then the parameters you want inside some nice ” ” (quotation marks?). As a random example it could be RANDOM_VARIABLE="uvesafb" .

Then follow the same steps I mentioned in the previous case about editing /etc/grub.d/30_os-prober, with the only difference that now you’ll add ${RANDOM_VARIABLE} (if it’s called RANDOM_VARIABLE, otherwise use the name you chose inside the braces) instead of ${GRUB_CMDLINE_LINUX_DEFAULT}. And don’t forget to save, close, and run update-grub!

Then you might want to check /boot/grub/grub.cfg just to see if everything worked fine (no editing, remember point 6?), but of course with a good lecturer like me you can’t have missed anything 🙂

Cheers to the people who will one day make a GUI for all these tasks (nooooooooooooooooooo not a GUI, that’s for nooooobs who’ll screw everything up and fill our bugzillas of stupid bugs THEY created by themselves!!)

Annunci