Skip to content

Instantly share code, notes, and snippets.

@nicksherron
Last active January 22, 2024 21:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicksherron/a3cf93920f74b24aca37f935730fc029 to your computer and use it in GitHub Desktop.
Save nicksherron/a3cf93920f74b24aca37f935730fc029 to your computer and use it in GitHub Desktop.
systemd service for disabling Transparent Huge Pages (THP) for dbs like mongodb and redis
[Unit]
Description=Disable Transparent Huge Pages (THP)
DefaultDependencies=no
After=sysinit.target local-fs.target
Before=mongod.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null'
[Install]
WantedBy=basic.target
@oscarcarlsson
Copy link

Is there any reason you echo into tee and then ignore the output? It seems backward, compared to just echoing (which returns no output).

@nicksherron
Copy link
Author

nicksherron commented Aug 3, 2022

yeah you can checkout this stack overflow discussion for the reasoning https://stackoverflow.com/a/550808
@oscarcarlsson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment