Solved

script to update kernel parameter in grub.conf

Posted on 2011-03-17
4
1,111 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
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

749 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