247

I need to add the boot parameter foo=bar to my kernel. How can I do this once for testing, and permanently if testing was a success?

3 Answers 3

349

To temporarily add a boot parameter to a kernel

  1. Start your system and wait for the GRUB menu to show (if you don't see a GRUB menu, press and hold the left Shift key right after starting the system).
  2. Now highlight the kernel you want to use, and press the e key. You should be able to see and edit the commands associated with the highlighted kernel.
  3. Go down to the line starting with linux and add your parameter foo=bar to its end.
  4. Now press Ctrl + x to boot.

To make this change permanent

  1. From a terminal (or after pressing Alt + F2) run:

     gksudo gedit /etc/default/grub
    

    (or use sudo nano if gksudo or gedit are not available) and enter your password.

  2. Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT and append foo=bar to its end. For example:

     GRUB_CMDLINE_LINUX_DEFAULT="quiet splash foo=bar"
    

    Save the file and close the editor.

  3. Finally, start a terminal and run:

     sudo update-grub
    

    to update GRUB's configuration file (you probably need to enter your password).

On the next reboot, the kernel should be started with the boot parameter. To permanently remove it, simply remove the parameter from GRUB_CMDLINE_LINUX_DEFAULT and run sudo update-grub again.

To verify your changes, you can see exactly what parameters your kernel booted with by executing cat /proc/cmdline.

Wiki page.

5
  • 2
    Shift doesn’t work for me. I used Esc instead. Had to be careful not to hold it too long or it would blow right through GRUB
    – eqzx
    Jul 7, 2018 at 3:18
  • 3
    gksudo is no longer in Ubuntu. Use pkexec instead.
    – Terrance
    Jun 27, 2019 at 14:12
  • 2
    Shift doesn't work when booting in UEFI mode, apparently. There, you have to press Esc repeatedly, but stop once you get to the GRUB menu or it'll drop to the GRUB shell. Dec 16, 2019 at 9:20
  • also see here for a sed command to get the variable
    – ukos
    May 9, 2021 at 9:59
  • For Archlinux, the command to update grub is grub-mkconfig -o /path/to/grub.cfg. See wiki.archlinux.org/title/kernel_parameters#GRUB
    – smac89
    Dec 7, 2023 at 3:30
17

To add any kernel option:

  • for a liveCD session: follow these steps

  • for an Existing Installation: use Boot-Repair's Add a kernel option or Edit GRUB configuration file options.

enter image description here

See also this documentation.

14

Alternatively, you may also use the handy grub-customizer:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
gksu grub-customizer &

Just open a boot entry, and edit its kernel parameters as highlighted in the screenshot below:

screenshot

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .