How would I persistently set a Linux kernel parameter?
How would I persistently set a Linux kernel parameter? Please give me an example.
To persistently set a Linux kernel parameter, you typically need to modify the system's bootloader configuration file. The specific steps and file location can vary depending on the Linux distribution and bootloader in use. Here's an example of persistently setting a kernel parameter using the GRUB bootloader:
Identify the Bootloader Configuration File:
- The GRUB bootloader configuration file is typically located at
/etc/default/grub
or/etc/grub.d/
. - Open a terminal and navigate to the appropriate directory for your system.
- The GRUB bootloader configuration file is typically located at
Edit the Bootloader Configuration File:
- Open the bootloader configuration file using a text editor with root privileges.
sudo vi /etc/default/grub
- Open the bootloader configuration file using a text editor with root privileges.
Find the Kernel Parameter Line:
- Look for the line starting with
GRUB_CMDLINE_LINUX
orGRUB_CMDLINE_LINUX_DEFAULT
. - This line specifies the kernel parameters passed to the Linux kernel during boot.
- Look for the line starting with
Add or Modify the Kernel Parameter:
- Add or modify the kernel parameter within the quotation marks.
- For example, to set the
net.core.somaxconn
parameter to2048
, you would add or modify the line to:GRUB_CMDLINE_LINUX="net.core.somaxconn=2048"
Save and Close the File:
- Save the changes you made to the bootloader configuration file.
- Close the text editor.
Update the Bootloader Configuration:
- Run the command to update the bootloader configuration based on the changes made.
sudo update-grub
- Run the command to update the bootloader configuration based on the changes made.
Reboot the System:
- Restart the system for the changes to take effect.
sudo reboot
- Restart the system for the changes to take effect.
After rebooting, the Linux kernel parameter you set in the bootloader configuration file will be applied persistently.
Please note that the specific steps may differ based on your Linux distribution and the bootloader in use (e.g., GRUB, LILO, systemd-boot). It's recommended to refer to the documentation or support resources specific to your distribution and bootloader for accurate instructions.