Solved

script to update kernel parameter in grub.conf

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Rate limit for DNS queries 7 83
awk to variable in bash 2 69
Quickest way to query Windows Event ID from a Linux Device 3 51
IP 10.0.1.2 / 255.0.0.0 61 56
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

809 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