Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have two Linux distributions (OpenSuSE, Ubuntu) installed on two different partitions. Each time i start my machine, GRUB loads up allowing me to select one of the two distributions.

I don't want the GRUB to show up so I limit timeout to zero in /boot/grub/menu.lst which will most probably make my machine load OpenSuSE each time i start my PC because it's the first option in the menu.lst.

Is it possible that the second time i restart my PC, Ubuntu gets loaded automatically? The third time i restart again, OpenSuSE may get booted while fourth time i restart, Ubuntu may load up and so on?

In other words how can i make my machine to boot the next OS in menu.lst, the next time it is restarted?

share|improve this question

migrated from stackoverflow.com Dec 28 '10 at 3:57

This question came from our site for professional and enthusiast programmers.

7  
Badge Unlocked: Strangest question of all time –  Mark Stahler Nov 20 '09 at 13:34
1  
Would you mind adding some detail: Are you using Karmic (which uses Grub2)? Also, do you share a /boot partition between both distros? Or does one distro's boot partition link to both distros kernel/initrd, etc? –  jhs Nov 20 '09 at 13:46
    
It's not weird at all! I used to do this with a dedicated Linux partition that would restore Windows using Partimage. Every other boot would go to Linux for a restore, then an immediate reboot back into Windows. (But I used LiLo then with the -R switch IIRC.) –  jhs Nov 20 '09 at 13:49

4 Answers 4

Put something in the startup scripts to rewrite menu.lst.

So have Ubuntu write a version of menu.lst that loads OpenSuSE, and have OpenSuSE write a version that loads Ubuntu.

A relatively safe way to do this would be to have 3 files, menu.lst, menu.lst.ubuntu and menu.lst.SuSE and have the scripts do:

cp menu.lst.ubuntu menu.lst

on SuSE and:

cp menu.lst.SuSE menu.lst

on Ubuntu.

share|improve this answer
    
Great minds....... –  jhs Nov 20 '09 at 13:41
    
This should work for me. Thanks rjmunro. –  baltusaj Nov 21 '09 at 15:15
up vote 9 down vote accepted

I attained the functionality I was looking for by using the 'savedefault' option of GRUB. I used to set it's value to the other operating system at the end of entry of each OS in menu.lst.

Thanks a lot to everyone who tried to help. :)

share|improve this answer
1  
+1 Was about to suggest savedefault, but you beat me to it ;) –  chris Feb 1 '11 at 17:08

Lilo can do this.

But you might consider a simple script in each OS that sets the other OS as the grub default. For example, the following script would modify a default 1 setting to default 0:

echo -e "g/default 1/d\ni\ndefault 0\n.\nw" | ed /boot/grub/menu.lst

(ed is much like Vi. Run just the first command to see what it's doing.)

On the other OS, you could run the counterpart:

echo -e "g/default 0/d\ni\ndefault 1\n.\nw" | ed /boot/grub/menu.lst
share|improve this answer
    
Thanks jhs. I think it will work out for me. But i will get to LILO if i fail to achieve the functionality with GRUB. –  baltusaj Nov 21 '09 at 15:14

What is your reason/objective to do this?

Have you considered just running two different virtual machines? If VMs can be considered, there are a number of different ways to accomplish this from within the host machine itself, without tampering with the guests.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.