How to persistently change /sys/kernel Linux settings now with the tuned package removed in Amazon Linux 2023?

0

With the tuned package now missing on current Amazon Linux, https://github.com/amazonlinux/amazon-linux-2023/issues/327:

Which cost-efficient simple alternative exists to persistently store Linux configurations for /sys/kernel over a reboot?

For our business needs we require to change /sys/kernel/mm/transparent_hugepage/shmem_enabled from the Amazon Linux 2023 default of "never" to "advise".

Previously on Amazon Linux 2 we could easily do that with the tuned package.

I see the sysfsutils package exists, but that's a different one than the identically named on Ubuntu where that package uses configuration files below /etc/sysfs.d for permanently modifying settings below /sys/kernel and the AL2023 version doesn't offer that functionality.

If you decide to change the shmem_enabled setting to advise as default, that would of course also help us and we wouldn't need to change the configuration anymore.

gefragt vor 2 Monaten205 Aufrufe
3 Antworten
0

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..

profile picture
EXPERTE
beantwortet vor einem Monat
  • 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.

0

A workaround would be to create a new system service of type Type=oneshot with RemainAfterExit=true.

beantwortet vor 2 Monaten
0

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.

beantwortet vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen