Solved

script to update kernel parameter in grub.conf

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now