Solved

script to update kernel parameter in grub.conf

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Merging two files with Perl 5 58
linux convert text file to PDF 7 71
unix shell script 4 41
How to really determine how many  files in hosting 2 35
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
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

738 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