Skip to content

Kernel arguments as array

EDIT: "${__defaults[@]@Q}" should be used, to allow arguments like acpi_osi='Windows 2009';

then if you check the generated configuration, you'll see every argument has been single-quoted:

linux	/boot/vmlinuz... root=... rw  'quiet' 'loglevel=3' 'acpi_osi=Windows 2009' ...

If you use a bootloader like GRUB which has a configuration file in bash syntax, you can put your kernel command line arguments as an array (obviously you must then join them as a single string).

In this way you can easily comment-out, change order (if important) and add explanation comments to your arguments.


I just tried this and it works flawlessly:

#!/bin/bash

GRUB_SAVEDEFAULT=true
#GRUB_DEFAULT=saved
GRUB_DEFAULT=0
GRUB_TIMEOUT=0
#GRUB_TIMEOUT_STYLE=hidden
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_DISABLE_OS_PROBER=true
GRUB_RECORDFAIL_TIMEOUT=0

GRUB_TERMINAL_INPUT='console usb_keyboard'
#GRUB_GFXMODE=800x600x24
#GRUB_GFXMODE=1024x768x24
#GRUB_GFXMODE=vga
GRUB_GFXMODE=auto
#GRUB_GFXPAYLOAD_LINUX=text
#GRUB_GFXPAYLOAD_LINUX=keep
GRUB_DISABLE_RECOVERY=true
GRUB_DISABLE_SUBMENU=y
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

GRUB_DISTRIBUTOR="Arch"
__defaults=(
    # Silent boot
    quiet
    loglevel=3
    #vga=current                  # disables kms
    rd.systemd.show_status=false
    rd.udev.log-priority=3
    vt.global_cursor_default=0    # no cursor
    splash                        # eye candy

    resume=UUID=e13fee37-b833-4ccd-82a7-30143dee4392
    nowatchdog                    # faster shutdown
    sysrq_always_enabled=1        # debug
    ahci.mobile_lpm_policy=1      # powersaving w/o drawbacks

    # Performance?
    i915.enable_dc=0
    intel_idle.max_cstate=1
    intel_iommu=on
    i915.disable_power_well=0

    # Good backlight
    i915.enable_dpcd_backlight=1
    acpi_backlight=vendor

    # https://make-linux-fast-again.com/
    noibrs
    noibpb
    nopti
    nospectre_v2
    nospectre_v1
    l1tf=off
    nospec_store_bypass_disable
    no_stf_barrier
    mds=off
    tsx=on
    tsx_async_abort=off
    mitigations=off
)
GRUB_CMDLINE_LINUX_DEFAULT="${__defaults[@]@Q}"
GRUB_CMDLINE_LINUX=""

#GRUB_COLOR_HIGHLIGHT="green/black"
#GRUB_COLOR_NORMAL="light-gray/black"
#GRUB_THEME=""
#GRUB_FONT=""

Edited 24 Apr 2021. We only hold this version.

18 points6 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
18 · 96% up
Kind
Text
ID
msoomo

Author

6
posts
4
comments
2
media
View profile

7 comments

Is there a rundown of exactly what the make-linux-fast-again options actually do? Some are obviously self-explanatory (the spectre stuff) but what are the others doing and are there any potential risks to using them?

6 points

It looks like a nice way of keeping track of which argument does what, for sure.

5 points

Does this work with GRUB Customizer?

1 points

Mmh I don't think so, it probably reads the file line-by-line expecting to find GRUB_CMDLINE_LINUX_DEFAULT as a single un-cutted string.

That's just my thought btw, you should check the source code.

3 points
unknown author

Deleted before we saved it.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.