Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-03-2009, 08:43 PM
|
#1
|
LQ Newbie
Registered: Jan 2009
Posts: 19
Rep:
|
changing default to zero
hi, i need to change the default boot order from any number to zero via a script. let me assume the following
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,2)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=1
timeout=10
splashimage=(hd0,2)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.27.5-117.fc10.i686)
root (hd0,2)
kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=108b1257-bc22-48d6-afab-2666b96d0dc8 rhgb quiet
initrd /initrd-2.6.27.5-117.fc10.i686.img
title Microsoft Windows Vista Ultimate
rootnoverify (hd0,0)
chainloader +1
here, the default boot order is 1. i need a script that would change it from 1 to 0 . i tried sed 's/default=[0-9]*/default=0/' /boot/grub/grub.conf
but it only displays the boot order changed to zero but in reality the boot order is the same . please help me.
|
|
|
04-03-2009, 08:53 PM
|
#2
|
Member
Registered: Apr 2004
Distribution: CentOS6, CentOS5, F16, F15, Ubuntu, OpenSuse
Posts: 620
Rep:
|
Why aren't you saving the output?
# sed 's/default=[0-9]*/default=0/' /boot/grub/grub.conf > /boot/grub/grub.conf
(make sure you keep an update of the original when doing this)
|
|
|
04-03-2009, 08:53 PM
|
#3
|
LQ Newbie
Registered: Jan 2009
Posts: 19
Original Poster
Rep:
|
it makes the file empty.
|
|
|
04-03-2009, 09:02 PM
|
#4
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
Quote:
Originally Posted by ramjgn
here, the default boot order is 1. i need a script that would change it from 1 to 0 . i tried sed 's/default=[0-9]*/default=0/' /boot/grub/grub.conf
but it only displays the boot order changed to zero but in reality the boot order is the same . please help me.
|
You would need to redirect this to a file to save it, like in:
Code:
sed -e 's/default=[0-9]*/default=0/' /boot/grub/grub.conf > grub.new
Then rename it. You can also make the mods on the fly, but then, make sure you make a backup of the relevant file(s) before, because there's no chance to go back of something goes wrong and your file is wiped or corrupted.
Code:
sed -e 's/default=[0-9]*/default=0/' -i /boot/grub/grub.conf
|
|
|
04-03-2009, 09:03 PM
|
#5
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
Code:
# sed 's/default=[0-9]*/default=0/' /boot/grub/grub.conf > /boot/grub/grub.conf
Quote:
Originally Posted by ramjgn
it makes the file empty.
|
Yes. That's wrong. You need to save to another file, or use -i as I told you above.
|
|
|
04-03-2009, 09:11 PM
|
#6
|
LQ Newbie
Registered: Jan 2009
Posts: 19
Original Poster
Rep:
|
the new file is also empty. i tried both the options you stated , well before posting the thread,but couldn`t do it . it doesn`t work. only empty file is created. may be a c program that will make use of array to check "default" and change the value from any number to zero would work. i should try it, if shell fails.
if you have some other suggestions or options, do post me.
|
|
|
04-03-2009, 09:18 PM
|
#7
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083
|
Quote:
Originally Posted by ramjgn
the new file is also empty. i tried both the options you stated , well before posting the thread,but couldn`t do it . it doesn`t work. only empty file is created. may be a c program that will make use of array to check "default" and change the value from any number to zero would work. i should try it, if shell fails.
if you have some other suggestions or options, do post me.
|
There's no reason why shell should fail. It works for everyone else. There's an error somewhere.
PS. If this command shows the correct output:
Code:
sed 's/default.*[0-9]*/default 0/' /boot/grub/grub.conf
Then, this one will write that output to a file as long as the input and output file are not the same:
Code:
sed 's/default.*[0-9]*/default 0/' /boot/grub/grub.conf > grub.new
And this one will edit the file in place:
Code:
sed 's/default.*[0-9]*/default 0/' /boot/grub/grub.conf -i
Last edited by i92guboj; 04-03-2009 at 09:26 PM.
|
|
|
04-03-2009, 11:20 PM
|
#8
|
LQ Newbie
Registered: Jan 2009
Posts: 19
Original Poster
Rep:
|
thanks for ur reply!!!! though the first two failed, last one, sed 's/default.*[0-9]*/default 0/' /boot/grub/grub.conf -i
successfully did the job. thank you
|
|
|
All times are GMT -5. The time now is 09:20 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|