1

I have several test servers that perform unit tests and hardware tests on some PCI and PCIe boards my company produces. These servers are multi-boot with a number of various Linux distributions and Windows editions installed. I'd like to automate the testing, however they'll need to be able to automatically reboot into the next operating system after the test suite is finished. Is there a way to reboot into a specific operating system, using bash/batch scripts?

They currently use GRUB, whatever version comes with Ubuntu 12.04, but I am not opposed to using a different bootloader if there's one that would make this easier.

TJ Mott
  • 11
  • 1
  • Thanks for the suggestions, it looks like I have some options at least. I haven't declared anything as the answer yet because I still haven't implemented anything due to other priorities, I'll be sure to check back if I get something working. – TJ Mott Mar 20 '14 at 17:48

2 Answers2

1

You could change the grub setting after each test, and set another (next) default boot option.

So after each test, you would modify the grub config, set the default boot option to the next OS installation, and reboot. This can be simply scripted in linux, but seems to be doable in Windows too (link).

mulaz
  • 10,472
  • 1
  • 30
  • 37
0

Risky and would require some testing, but why don't you script it?
Generate your grub.conf via shell script, and have your shell script run on bootup (e.g. put it in rc.local)

Put your scripts in /root/grubscript

Have a wrapper called /root/grubscript/wrapper.sh (which is run by rc.local)

Let's say you have four OS, you would create four grub files

/root/grubscript/grub.conf.1.txt
/root/grubscript/grub.conf.2.txt
/root/grubscript/grub.conf.3.txt
/root/grubscript/grub.conf.4.txt

Your wrapper script will do this (assuming grub.conf is in /boot/grub/grub.conf)

#!/bin/bash

cp -p /root/grubscript/grub.conf.1.txt /boot/grub/grub.conf 
mv /root/grubscript/grub.conf.1.txt /root/grubscript/grub.conf.5.txt
mv /root/grubscript/grub.conf.2.txt /root/grubscript/grub.conf.1.txt
mv /root/grubscript/grub.conf.3.txt /root/grubscript/grub.conf.2.txt
mv /root/grubscript/grub.conf.4.txt /root/grubscript/grub.conf.3.txt
mv /root/grubscript/grub.conf.5.txt /root/grubscript/grub.conf.4.txt

You get the idea. Test it manually first by running it from the command line and check that the /boot/grub/grub.conf rotates properly

Finally, for contingency sake, first backup your current grub.conf

cp -p /boot/grub/grub.conf /boot/grub/grub.conf.ORIGINAL

And have an install dvd handy to boot into rescue mode if during your reboots one of your grub files isn't working

Does this help?

ben
  • 101
  • 5