Solved

script to update kernel parameter in grub.conf

Posted on 2011-03-17
4
1,136 Views
Last Modified: 2012-06-21
Hi

Could you please help me to create a shell script to update kernel parameter in grub.conf. As per the VMware KB

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427

I need to add the kernel parameter. I need to do this for RHEL4 64bit systems. I have below given kernels to modify.

2.6.9-89.0.23 with this I need to add notsc
2.6.18-128 with this I need to add notsc divider=10
2.6.9-55 with this I need to add notsc

Any help will be appreciated.

0
Comment
Question by:upanwar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Assisted Solution

by:Alberto Cortes
Alberto Cortes earned 167 total points
ID: 35158270
I recommend you to edit /boot/grub/grub.conf and add the parameters as follows:
1. cp /boot/grub/grub.conf /boot/grub/grub.conf.old
2. vi /boot/grub/grub.conf
3. Add parameters to the end of the line, for example:
Original line is:
    kernel /vmlinuz-2.6.18 ro root=/dev/hda2
and you want to add "notsc divider=10", the updated text is:
    kernel /vmlinuz-2.6.18 ro root=/dev/hda2 notsc divider=10
4. Save and test by rebooting.
0
 
LVL 8

Accepted Solution

by:
pilson66 earned 166 total points
ID: 35164490
For quick editing, you can use a utility "sed"
Example:
 
sed -i 's/kernel \/vmlinuz-2.6.18 ro root=\/dev\/hda2$/kernel \/vmlinuz-2.6.18 ro root=\/dev\/hda2 notsc divider=10/g' /boot/grub/grub.conf

Open in new window

But in this case, no backup is created.
0
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 167 total points
ID: 35169697
You can do this:
sed -i -e "s/kernel.*/& notsc/" -e "s/.*2.6.9-55.*/& divider=10/" /boot/grub/grub.conf

Open in new window


Having said that, why are you doing this.  Scripts are written to tasks that are recurring.  Seems like you have to modify it just once.

Furthermore, I think what you are really looking for is: having kernel parameters appropriate to whatever kernel you select.

To accomplish that, what you should do is this:

Add a little script in your /etc/rc.d/rc.local.

Find the name of the kernel with uname and do write the /proc/ values of these parameters

Something like
[[ $(uname -a) =~ '2.6.9-89.0.23' ]] && /proc/path/file > value

I don't even have a RHEL 4 system anymore, but this is what I would think
0
 
LVL 12

Author Closing Comment

by:upanwar
ID: 35181005
I have managed to write it with the help of grubby. Which is great. But anyways everybody have put their efforts so thanks all of you.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question