How do I enable transparent huge pages by default on Ubuntu?

Daniel picture Daniel · Apr 18, 2013 · Viewed 17.6k times · Source

How do I enable transparent huge pages by default on Ubuntu?

~$ uname -a
Linux yoda 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
~$ cd /sys/kernel/mm/transparent_hugepage/
/sys/kernel/mm/transparent_hugepage$ ls
defrag  enabled  khugepaged
/sys/kernel/mm/transparent_hugepage$ cat enabled 
always [madvise] never
/sys/kernel/mm/transparent_hugepage$ sudo echo always > enabled 
-bash: enabled: Permission denied
/sys/kernel/mm/transparent_hugepage$ sudo ls
[sudo] password for <...>: 
defrag  enabled  khugepaged
/sys/kernel/mm/transparent_hugepage$ sudo ls
defrag  enabled  khugepaged
/sys/kernel/mm/transparent_hugepage$ sudo echo always > enabled 
-bash: enabled: Permission denied
/sys/kernel/mm/transparent_hugepage$ cat enabled 
always [madvise] never

Answer

user2753332 picture user2753332 · Sep 6, 2013

Adding the following:

transparent_hugepage=always

to GRUB_CMDLINE_LINUX_DEFAULT in your:

/etc/default/grub

and doing a:

update-grub

should do the trick.