Skip to content

Instantly share code, notes, and snippets.

@vlasky
Created March 6, 2018 06:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlasky/6a26961f0eaa8898f6cf992c4718421e to your computer and use it in GitHub Desktop.
Save vlasky/6a26961f0eaa8898f6cf992c4718421e to your computer and use it in GitHub Desktop.
Systemd startup script to automatically disable Transparent Huge Pages (THP) under Linux. This must be done before launching MySQL with the TokuDB storage engine or before launching MongoDB.
# Copy this file to /etc/systemd/system/
# Then run:
# systemctl enable disable_transparent_huge_pages.service
# systemctl start disable_transparent_huge_pages.service
[Unit]
Description=Disable transparent huge pages
[Service]
Type=oneshot
ExecStart=/bin/sh -c "/usr/bin/echo never | /usr/bin/tee /sys/kernel/mm/transparent_hugepage/enabled"
ExecStart=/bin/sh -c "/usr/bin/echo never | /usr/bin/tee /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment