I want to have a separate boot menu entry at boot. The only difference is the value of GRUB_CMDLINE_LINUX_DEFAULT. The original (first) boot has empty value for GRUB_CMDLINE_LINUX_DEFAULT, and the 2nd entry has a value that is passed to the kernel.

In short, I want to have two boot menu entries which the only difference is the kernel arguments. I poked around /etc/grub.d but couldn't find a way other than gross hack in /etc/grub.d.

  • 1
    Copy boot stanza into 40_custom and add whatever entries you want. With Ubuntu you can use the linked kernel files, so always booting most recent. See: help.ubuntu.com/community/MaintenanceFreeCustomGrub2Screen
    – oldfred
    Commented Jun 30, 2019 at 19:43
  • 1
    It's not very portable. I do not like to hardcode the menu entry. Commented Jun 30, 2019 at 19:51
  • 1
    It is really dumb this is so hard.
    – BeeOnRope
    Commented Jan 11, 2020 at 22:06

3 Answers 3


Here's what I did on 16.04:

First add an entry for your alternate command line in /etc/default/grub1:

export GRUB_CMDLINE_LINUX_2="quiet splash mitigations=off"

Of course, change the content to reflect the arguments you'd like! Note that you need export as shown, even though the existing GRUB_CMDLINE... variables don't need it: because the existing known variables are exported somewhere else inside grub-mkconfig.

Second, edit /etc/grub.d/10_linux to add a new linux_entry line which will generate your new menu item. Where you put this in the file determines where it shows up, but to have it show up right below the first, default, option, but it here:

  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
    linux_entry "${OS}" "${version}" simple \

    # START
    linux_entry "${OS} (mitigations off)" "${version}" simple \
    # END

The newly added stuff is between # START and # END and the entry immediately above is the existing one that generates the default option. You could basically copy the prior entry, but change GRUB_CMDLINE_LINUX_DEFAULT to GRUB_CMDLINE_LINUX_2, and give it a unique name (in my case, I appended (mitigations off}).

Now this menu entry will be generated in the same way as the default entry, except using different command line args. You could also add to the default args with additional args, rather than replacing them, which is actually what I did, e.g.:


where ${GRUB_CMDLINE_EXTRA} are the extra args I wanted in addition to the default args.

Run sudo update-grub and you're good to go.

1 Strictly speaking, you don't need this: you could just put the values directly into the 10_linux linux_entry in the next step, but this keep things a bit clear and lets you create multiple entries with the new command line if you'd like. One problem is that you may occasionally get merge conflicts when /etc/default/grub gets updated (generally, they should be easy to resolve: you just want the default file plus your export ... line).


I solved this with rerunning /etc/grub.d/10_linux from /etc/grub.d/40_linux, and picking off the menu entry.

First part is /etc/grub.d/40_linux

. /etc/default/grub
/etc/grub.d/10_linux | python3 /usr/local/bin/extract-menuentry.py

So, I can rerun the 10_linux with alternate command line.

Put in the GRUB_CMDLINE_LINUX_DEFAULT_ALT in the /etc/default/grub. (In my case, "aufs=tmpfs")

And wrote a python script to pick off the menu entry. (in /usr/local/bin/extract-menuentry.py in my case.)

#!/usr/bin/env python3
import os, sys, re

menuentry_start = "menuentry"

def extract_menuentry(infile):
  in_menuentry = False
  for line in infile.readlines():
    if in_menuentry:
      if line.strip() == "}":
        in_menuentry = False
      if line.startswith(menuentry_start):
        in_menuentry = True
        match = re.search(r"menuentry '[^']+' (.*)", line)
        print("menuentry '%s' %s" % (os.environ.get('GRUB_ALT_NAME', 'Ubuntu alt'), match.group(1)))

if __name__ == "__main__":

Two ways:

  1. Quick, easy, and with a GUI interface: install grub-customizer.

    sudo apt update && sudo apt install grub-customizer
  2. Go into /etc/grub.d/proxifiedScripts and add a custom entry named custom1 (you can copy the configuration from your default entry in /boot/grub/grub.cfg)

    cd /etc/grub.d/proxifiedScripts sudo leafpad custom1 &

The custom1 entry can look like this for example, and you can customize the default boot options in the line that starts with linux

menuentry "Custom Gnu/Linux"{
    insmod gzio
    if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos5' [YOUR CORRESPONDING ROOT LOCATION]
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=[YOUR CORRESPONDING ROOT LOCATION] --hint-efi=[YOUR CORRESPONDING ROOT LOCATION] --hint-baremetal=ahci0,msdos5  [UUID of / partition]
      search --no-floppy --fs-uuid --set=root [UUID]
    echo    'Loading Linux custom1 ...'
    linux   /boot/[your vmlinuz] root=UUID=[UUID] ro initrd=/install/gtk/initrd.gz quiet splash acpi_osi=linux
    echo    'Loading initial ramdisk ...'
    initrd  /boot/[your initrd.img]

Then you have to edit (or create if not there) 40_custom_proxy in /etc/grub.d/ t

'/etc/grub.d/proxifiedScripts/custom1' | /etc/grub.d/bin/grubcfg_proxy "-*
+'Custom1 Gnu/Linux'~f993006fab178e9acbf3ae439d2495c0~

and finally run sudo grub-mkconfig and sudo update-grub

However, option 1 is the one I would recommend, as it is cleaner faster and easier.

You must log in to answer this question.

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