Results 1 to 7 of 7
Can I make changes to /etc/boot/grub/menu.lst from the GRUB Menu that says 'Hi' to me when my machine boots up?
e.g. Linux is installed in (hd0,0) and windows in (hd0,5). ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-29-2009 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 12
[SOLVED] Making changes in menu.lst from GRUB at boot time?
Can I make changes to /etc/boot/grub/menu.lst from the GRUB Menu that says 'Hi' to me when my machine boots up?
e.g. Linux is installed in (hd0,0) and windows in (hd0,5). The windows' one is set to default in /etc/boot/grub/menu.lst. Now when my machine boots up, I want my windows to boot up BUT I also want that the next time when I restart, Linux must boot up by default.
For doing so, can I make changes in /etc/boot/grub/menu.lst (setting default to linux) from the GRUB Menu before the Windows start booting?
- 12-29-2009 #2
I'm not sure quite what you mean.
Do you want to alternate between Windows and Linux each time you boot the system or always want Linux to be the default?
Does grub show a menu when you first start the system or is that also something you are trying to get grub to do?
What distro are you using?
Can you post the output of
Code:cat /boot/grub/menu.lst
- 12-30-2009 #3Just Joined!
- Join Date
- Dec 2009
- Posts
- 12
Do you want to alternate between Windows and Linux each time you boot the system? Yes
Does grub show a menu when you first start the system? Yes
What distro are you using? I am using Ubuntu but I don't think It matters anything.
Let me describe a little more:
Following is my menu.lst
You can see that my default is set to 0 and the timeout is set to 5 so when my machine starts, i get a grub menu that counts down from 5. If don't select anything, Windows will boot up for the default = 0. Now, It's OK to me if Windows boot up but what I want is that the next time the machine starts the default must be equal to 1 so that Linux may automatically start then after 5 sec.Code:# menu.lst - See: grub(8), info grub, update-grub(8) # grub-install(8), grub-floppy(8), # grub-md5-crypt, /usr/share/doc/grub # and /usr/share/doc/grub-doc/. ## default num # Set the default entry to the entry number NUM. Numbering starts from 0, and # the entry number 0 is the default if the command is not used. # # You can specify 'saved' instead of a number. In this case, the default entry # is the entry saved with the command 'savedefault'. # WARNING: If you are using dmraid do not use 'savedefault' or your # array will desync and will not let you boot your system. default 0 ## timeout sec # Set a timeout, in SEC seconds, before automatically booting the default entry # (normally the first entry defined). timeout 5 ## hiddenmenu # Hides the menu by default (press ESC to see the menu) hiddenmenu # Pretty colours color cyan/blue white/blue ## ## End Default Options ## title Windows root (hd0,2) makeactive chainloader +1 title Ubuntu 9.04, kernel 2.6.28-16-generic uuid bfd832e4-d1ac-4335-a6b2-31efcfd47be7 kernel /boot/vmlinuz-2.6.28-16-generic root=UUID=bfd832e4-d1ac-4335-a6b2-31efcfd47be7 ro quiet splash initrd /boot/initrd.img-2.6.28-16-generic quiet
Hope that make some sense now.
- 12-30-2009 #4
Is there a reason you can't use the Up/Down arrows to select which system you want to boot?
- 12-30-2009 #5Just Joined!
- Join Date
- Dec 2009
- Posts
- 12
Yes, there is a very good reason for that. I want to set the timeout equal to zero 'ultimately' so that everything seems automatic then i.e. the user will not be able to select any OS from the menu. He will just get Windows one time, Linux the second time and Windows again the next time he restarts his machine and so on...
- 12-31-2009 #6
Modifications required to grub menu.lst file
I wanted to know the distro because this affects which version of grub is used ...
Modified information below should do what you want ...
in summary you need to comment out hiddenmenu, change default to saved rather than 0, add savedefault entry to each menu entry so next boot uses other menu entry as default.
Let use know if it works for youCode:# menu.lst - See: grub(8), info grub, update-grub(8) # grub-install(8), grub-floppy(8), # grub-md5-crypt, /usr/share/doc/grub # and /usr/share/doc/grub-doc/. ## default num # Set the default entry to the entry number NUM. Numbering starts from 0, and # the entry number 0 is the default if the command is not used. # # You can specify 'saved' instead of a number. In this case, the default entry # is the entry saved with the command 'savedefault'. # WARNING: If you are using dmraid do not use 'savedefault' or your # array will desync and will not let you boot your system. default saved ## timeout sec # Set a timeout, in SEC seconds, before automatically booting the default entry # (normally the first entry defined). timeout 5 ## hiddenmenu # Hides the menu by default (press ESC to see the menu) # hiddenmenu # Pretty colours color cyan/blue white/blue ## ## End Default Options ## title Windows root (hd0,2) makeactive savedefault 1 chainloader +1 title Ubuntu 9.04, kernel 2.6.28-16-generic uuid bfd832e4-d1ac-4335-a6b2-31efcfd47be7 savedefault 0 kernel /boot/vmlinuz-2.6.28-16-generic root=UUID=bfd832e4-d1ac-4335-a6b2-31efcfd47be7 ro quiet splash initrd /boot/initrd.img-2.6.28-16-generic quiet

Ed: I suggest even after you get this to work the way you want you leave a time delay of 1 second, this allows you to break into the boot process if you need to after kernel updates etc
- 12-31-2009 #7Just Joined!
- Join Date
- Dec 2009
- Posts
- 12
That's AWESOME Jonathan....I thought there is no solution so I downloaded the source of GRUB and began amending my code to grub/main.c
but while I was finding out a way to run bash script from a c file, I found your answer.
I tested it and it did the magic for me.
You were right when you asked me about the distribution I was using because on another machine of mine this savedefault returns an Error 15: File not found which is because of the old grub version, I guess.
Thanks a lot Jonathan. I am loving Linux.



