15

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?

Sildoreth
  • 1,884
Uthman
  • 351
  • 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? –  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.) –  Nov 20 '09 at 13:49

4 Answers4

11

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.

tshepang
  • 65,642
rjmunro
  • 1,054
9

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. :)

Uthman
  • 351
3

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
  • 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. –  Nov 21 '09 at 15:14
2

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.

sybreon
  • 724