- Newest
- Most votes
- Most comments
Use the sysfsutils
package. This package allows modifying settings under /sys/kernel
by creating configuration files under /etc/sysfs.d
Settings in these configuration files will apply on each reboot.
Use a configuration management tool like Ansible to modify the /sys/kernel
setting and store the configuration. On reboot, Ansible can be used to re-apply the configuration.
Modify the GRUB configuration file (/etc/default/grub
) to pass the required kernel parameter on boot. For example, to change the
transparent_hugepage
setting, add transparent_hugepage=never
to the GRUB_CMDLINE_LINUX
variable. Then run grub2-mkconfig -o /boot/grub2/grub.cfg
to generate the config file..
A workaround would be to create a new system service of type Type=oneshot with RemainAfterExit=true.
I'm now continuing with the solution as simple single-file system service as that works fine. Using the following systemctl service parameters to get it set early enough before apps are started:
[Unit]
Requires=local-fs.target
Before=network.target
[Service]
Type=oneshot
RemainAfterExit=true
If anyone knows better ways to persistently easily configure Linux /sys settings please comment.
Relevant content
- Accepted Answerasked a year ago
- Accepted Answerasked 7 months ago
- asked 7 months ago
- AWS OFFICIALUpdated 19 days ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 2 years ago
On Ubuntu using the sysfsutils package was indeed already our solution on that OS, but on Amazon Linux 2023 the sysfsutils package looks different and it didn't include the /etc/sysfs.d/ file structure and no system service, just a library. Or has that changed the recent few weeks?
The GRUB configuration works for the standard transparent_hugepage setting, but not for the special shmem_enabled we need.