Is it possible to add a kernel parameter and load it without a reboot?

I was wondering if there is a way to add a bunch of kernel parameters, namely:

rd.driver.pre=vfio-pci kvm.ignore_msrs=1 i915.enable_gvt=1 intel_iommu=on amd_iommu=on iommu=1

and then tell the system to use them immediately so that a reboot isn’t necessary.

I’m currently adding the kernel parameters by changing /etc/default/grub and then running grub2-mkconfig > /etc/grub2-efi.cfg. But that appears to require a reboot.

A very good question.
Basically kernel parameter can be changed during runtime.
However, not every kernel parameter can or should be changed.

There are at least two locations where you can see or modify such parameters:
/sys # sysfs; information about devices, drivers, and some kernel features, only a few writeable, mostly readonly
/proc # procfs; process and system information, mostly writable

You can find and change certain kernel parameter by editing those files.
They don’t survive a reboot and many only apply to new sessions or new started processes.
Lets say you change a process limit, an already running process and its children still use the old limit.

But this depends on the setting.
For example, you can switch on/off Hyperthreading in runtime by this commands:
echo off > /sys/devices/system/cpu/smt/control
echo on > /sys/devices/system/cpu/smt/control

for details see
man 5 procfs
man 5 sysfs

That was kind of the old way.

Newer way:

You also can change kernel parameter using the command “sysctl”.
man sysctl
sysctl -a
sysctl --system
and so on.

Using sysctl is the “new” way to handle it.
You can search for a parameter easily for example by:
sysctl -a 2> /dev/null | grep ipv6 | grep disable

And then you can change something by
sysctl -w net.ipv6.conf.all.disable_ipv6=1

To make changes permanent, place an additional file into
/etc/sysctl.d/

Can look like:
touch /etc/sysctl.d/90-ipv6.conf

And use an editor of you choice to add something like:

cat /etc/sysctl.d/90-ipv6.conf

# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

The Documentation can be found at kernel.org, like
The Linux kernel user's and administrator's guide — The Linux Kernel documentation
Documentation for /proc/sys — The Linux Kernel documentation
IPv6 — The Linux Kernel documentation
IP Sysctl — The Linux Kernel documentation
The kernel's command-line parameters — The Linux Kernel documentation

Edit
to be more detailed

3 Likes

Is there a place where all this information is documented for each kernel parameter?

Ah, yes, sorry, this is because “echo” is a bash included command.

This circumstances make the command a bit more complicated, so
sudo -u root bash -c 'echo off > /sys/devices/system/cpu/smt/control'
sudo -u root bash -c 'echo on > /sys/devices/system/cpu/smt/control'
works.

Or just do
sudo su -
to become root.
Then this should work without sudo
echo on > /sys/devices/system/cpu/smt/control

1 Like

At kernet.org.

https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

1 Like