Hello
I wrote a program but what beats me is the print works fine and gives me the expected output fir it does not write the same to the file
File.open("/tmp/grub.conf","r").each_line do |line|
file_boot=File.open("/tmp/bootfile","w")
data = line.split(" ")
if data[0] == "kernel"
data_len=data.length
if data[data_len-1].strip == " transparent_hugepage=never"
file_boot.write(line)
print line
else
line1=line.tr("\n","")+" transparent_hugepage=never"+"\n"
file_boot.write(line1)
print line1
end
else
file_boot.write(line)
print line
end
end
Output Printed
===============
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/rootvg-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.32-696.23.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-696.23.1.el6.x86_64 ro root=/dev/mapper/rootvg-lv_root rd_LVM_LV=rootvg/lv_root rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet elevator=noop
transparent_hugepage=never transparent_hugepage=never
initrd /initramfs-2.6.32-696.23.1.el6.x86_64.img
title Red Hat Enterprise Linux Server (2.6.32-696.18.7.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-696.18.7.el6.x86_64 ro root=/dev/mapper/rootvg-lv_root rd_LVM_LV=rootvg/lv_root rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet elevator=noop
transparent_hugepage=never transparent_hugepage=never
initrd /initramfs-2.6.32-696.18.7.el6.x86_64.img
title Red Hat Enterprise Linux Server (2.6.32-696.3.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-696.3.1.el6.x86_64 ro root=/dev/mapper/rootvg-lv_root rd_LVM_LV=rootvg/lv_root rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet elevator=noop
transparent_hugepage=never
initrd /initramfs-2.6.32-696.3.1.el6.x86_64.img
Stored in file
==============
initrd /initramfs-2.6.32-696.3.1.el6.x86_64.img t=/dev/mapper/rootvg-lv_root rd_LVM_LV=rootvg/lv_root rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet elevator=noop transparent_hugepage=never
transparent_hugepage=never
On Thursday, July 19, 2018 at 4:49:14 PM UTC-5, Mohan Mohta wrote:
Hello
I am trying to update /boot/grub/grub.conf
I need to disable huge page on the server and the way to do it is adding the following parameter at the end of the line which specifies which kernel boots up
transparent_hugepage=never
Can you let me know how can this be done via ruby
Sample file
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/rootvg-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.32-696.23.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-696.23.1.el6.x86_64 ro root=/dev/mapper/rootvg-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=768M rd_NO_DM KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=rootvg/lv_root transparent_
hugepage=never
initrd /initramfs-2.6.32-696.23.1.el6.x86_64.img
title Red Hat Enterprise Linux Server (2.6.32-696.18.7.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-696.18.7.el6.x86_64 ro root=/dev/mapper/rootvg-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=768M rd_NO_DM KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=rootvg/lv_root transparent_
hugepage=never
initrd /initramfs-2.6.32-696.18.7.el6.x86_64.img
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)