Load windows from within Linux

3

I have an unusual question and I think it is really hard :-)

What I want to achive is a way to be able to remotly configure which operating system is booted on a client machine.

E.g. I have Windows XP on Partition 1 and Win7 on Partition 2. I now want to switch on the computer and have it wait for a remote command to decide which partition to boot.

I first tried to do this with grub. Grub can boot and wait for commands on the serial console. On this serial console I can then send commands from a second pc to decide which partition to boot. Unfortunately this only works over traditional com ports. The USB to serial adapters do not work :-(

Therefore I thought I could boot into a mini Linux and open a TCP socket. After the arrival of a command I would like to boot (somehow chainload) one of the windows partitions. Is something like this possible?

Thanks a lot, Fabian

Fabian

Posted 2011-06-16T14:08:40.943

Reputation: 113

Answers

1

I am answering my own question here, since I implemented something slightly different from what was suggested.

I have configured grub with this config:

# First we load the current settings
if [ -s $prefix/grubenv ]; then  
  load_env  
fi

set default="DEFAULT ENTRY"

# Load the saved default entry
if [ ${saved_entry} ]; then
  echo Found a saved entry: ${saved_entry}
  set default="${saved_entry}"
fi

# Reset saved_entry to our boot service
set saved_entry="DEFAULT ENTRY"
save_env saved_entry

echo Selected boot entry is: ${default}

This is simmilar to Daves answer except that grub is already resetting the boot entry to a default value. Therefore the last selected os does not even has to boot.

The default entry now boots a small os with a tcp server. With the tcp server I can receive a boot command which calls grub-editenv to select a different boot entry:

grub-editenv.exe D:\boot\grub\grubenv set saved_entry=NewEntry

This should also make sure to not inadvertently corrupt the grub config.

Fabian

Posted 2011-06-16T14:08:40.943

Reputation: 113

2

if you have a separate, always running linux on your network, you could configure your machine to boot over network from this linux machine. Then, on this linux machine you could serve different boot images with grub loading either OS as default option.

kresho

Posted 2011-06-16T14:08:40.943

Reputation: 21

Unfortunately this is no option for me, we already have a dhcp and tftp server on the network which serves images to the ip telefones. So it would be quite risky to run another one. – Fabian – 2011-06-16T15:10:02.850

2

An idea: Add an additional OS that's a mini Linux as you mention. It opens this TCP socket. When you get the command, modify the GRUB config file to set the default to be the correct OS and initiate the reboot. Once any of those OS starts up, they need to re-modify the GRUB config script to go back to the mini Linux.

Dave

Posted 2011-06-16T14:08:40.943

Reputation: 71

This looks like the way I have to go, unfortunately I also remotely install stuff on the bootet partition so that it might even no longer boot. So it might never get to the point where it resets the grub config. Therefore I also have a third partition which when booted restores the first two partitions to a sane state. This is all for a test setup. – Fabian – 2011-06-16T15:13:50.833

1

Don't do any of that. Instead, put Xen (HyperV, etc.) on the box and always boot that, then control VMs of Windows and Linux at will.

Got to be easier than trying to remotely rewrite Grub config files, which can potentially leave you with an unbootable device.

In my experience, VMs are great for testing anyway--if you make a mistake you can just revert to an earlier state.

CarlF

Posted 2011-06-16T14:08:40.943

Reputation: 8 576

0

Another idea: have two GRUBs stored on your "control pc". The PC that is being controlled then uses PXE to retrieve the GRUB you want. Use a TFTP server for this. Make a little script that switches out the GRUB settings in the TFTP part.

sinni800

Posted 2011-06-16T14:08:40.943

Reputation: 3 048

Kresho had the same idea, my post is useless ;D – sinni800 – 2011-06-16T15:02:44.653

0

well.... you may get a KVM redirector over network device. Eg. AMI Mega RAC cards. They allow you to control from the boot screen.

Balaji S

Posted 2011-06-16T14:08:40.943

Reputation: 1