Complex edits on /etc/default/grub (Setting transparent_hugepage at boot time)

556 views
Skip to first unread message

Tom Limoncelli

unread,
Jul 29, 2015, 5:30:53 PM7/29/15
to puppet...@googlegroups.com
I need to disable transparent_hugepage at boot time (before some big
services start up). This is on centos7 machines using SystemD.

There are many ways to do this. It isn't clear which is the
best/easiest way to do it via puppet. (Here is a list of ways to do
it manually http://answers.splunk.com/answers/188875/how-do-i-disable-transparent-huge-pages-thp-and-co.html
and here is one more
http://docs.mongodb.org/manual/tutorial/transparent-huge-pages/)

The most straightforward way seems to be to edit /etc/default/grub:

Change this line in /etc/default/grub and add
transparent_hugepage=never to the GRUB_CMDLINE_LINUX.

i.e.

Change this line:

GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_ks-7/root
rd.lvm.lv=centos_ks-7/swap crashkernel=auto
vconsole.font=latarcyrheb-sun16 vconsole.keymap=us
intel_pstate=disable rhgb quiet transparent_hugepage=never"

to

GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_ks-7/root
rd.lvm.lv=centos_ks-7/swap crashkernel=auto
vconsole.font=latarcyrheb-sun16 vconsole.keymap=us
intel_pstate=disable rhgb quiet transparent_hugepage=never"

However doing that in puppet (even with Augeas) seems non-trivial.



Any suggestions?

Tom

P.S. I'm also considering making a systemd "unit" that just sets the
parameter and is scheduled to run before any of the major services on
the machine. However that seems like a long way to do a short thing.

--
Email: t...@whatexit.org Work: tlimo...@StackOverflow.com
Skype: YesThatTom
Blog: http://EverythingSysadmin.com

Tom Limoncelli

unread,
Jul 29, 2015, 6:02:11 PM7/29/15
to puppet...@googlegroups.com
Of course, minutes after emailing that I found the answer to my own question.

If you install the augeasproviders_grub module (https://github.com/hercules-team/augeasproviders_grub) then it becomes as simple as:

    kernel_parameter { 'transparent_hugepage':
      value => 'never',
      ensure => present,
    }

In CentOS7, the module is smart enough to make the change to /etc/default/grub's GRUB_CMDLINE_LINUX variable.  From a quick look at the code, it seems to do the right thing for other OSs too.

The Augeas people never fail to impress!

Tom

Brad Knowles

unread,
Jul 29, 2015, 6:10:36 PM7/29/15
to puppet...@googlegroups.com, Brad Knowles
On Jul 29, 2015, at 5:01 PM, Tom Limoncelli <t...@whatexit.org> wrote:

> The Augeas people never fail to impress!

So long as you’re not trying to edit XML files with Augeas. That’s 80% of the way there, maybe even 90% of the way there.

But that last 10-20% will drive you absolutely bloody batshit insane.

--
Brad Knowles <br...@shub-internet.org>
LinkedIn Profile: <http://tinyurl.com/y8kpxu>

signature.asc

Raphaël Pinson

unread,
Aug 4, 2015, 8:08:21 AM8/4/15
to Puppet Users

On Thursday, July 30, 2015 at 12:02:11 AM UTC+2, Tom Limoncelli wrote:
Of course, minutes after emailing that I found the answer to my own question.

If you install the augeasproviders_grub module (https://github.com/hercules-team/augeasproviders_grub) then it becomes as simple as:

    kernel_parameter { 'transparent_hugepage':
      value => 'never',
      ensure => present,
    }

In CentOS7, the module is smart enough to make the change to /etc/default/grub's GRUB_CMDLINE_LINUX variable.  From a quick look at the code, it seems to do the right thing for other OSs too.

The Augeas people never fail to impress!



Glad it's useful to someone :-)


Raphaël

Raphaël Pinson

unread,
Aug 4, 2015, 8:08:45 AM8/4/15
to Puppet Users, br...@shub-internet.org


On Thursday, July 30, 2015 at 12:10:36 AM UTC+2, Brad Knowles wrote:
On Jul 29, 2015, at 5:01 PM, Tom Limoncelli <t...@whatexit.org> wrote:

> The Augeas people never fail to impress!

So long as you’re not trying to edit XML files with Augeas.  That’s 80% of the way there, maybe even 90% of the way there.


Arguably, I think a real XML type with XPath changes would be better than using Augeas (which has limited XML support).  So far, it's still the best option there is, though. Also, it's easier to make it idempotent than using XPath with, say, Nokogiri.


Raphaël

Reply all
Reply to author
Forward
0 new messages