Yesterday, I blogged how to add a Windows hard disk to a Linux installation. I noted, it’s relatively easy to add a Linux disk to a Windows installation, and how the Windows MBR gets overwritten by Linux. But it’s harder to add a Windows disk to an existing Linux installation. The whole process with Supergrub was rather complex, and required many slow reboots.
After thinking about it, a much simpler and effective method came to me. And it works!
In a sentence, the trick is to just modify the boot order in the BIOS, and add the Windows disk to grub.conf. Here’s how to do it.
With only one disk in the server, install Linux, or start with the existing Linux hard disk. It will have a modified Master Boot Record (MBR) and grub.conf in the /boot partition. It will look something like:
MBR | /boot | / | swap
In grub.conf, this Linux disk will be recognized as (hd0,0).
Reboot, and make sure that it boots to Linux easily enough.
Disconnect the Linux hard disk, insert a second disk for Windows. With this hard disk as the only disk in the machine, install Windows on it. It will look something like:
MBR | C: | Possible other partitions
Connect Both Disks and Modify grub.conf:
Connect both disks. In the BIOS, ensure that the Linux hard disk is the first in the boot order, and Windows second. Boot to Linux.
In Linux, modify grub.conf and append the Windows configuration to the bottom of the file.
Note that this Windows hard disk is the second disk: (hd1,0).
Set the default operating system to boot to. The first one in the list defaults to zero:
Test with a reboot.
The advantage of this method is that the two hard disks no longer need to be married to each other. If you remove the Windows disk, Linux still boots fine, as long as Linux is the only hard disk in the server. If you remove Linux, Windows still boots fine, as long as Windows is the only hard disk in the server. Cool!
This is so simple! I can’t help wonder, why is this not well known? I think because we (I) have always installed grub on the MBR during the Linux installation. Grub is not that intuitive. You have to read, think about it, and digest it. During a Linux installation, if it works, you just want to get on with the other software that’s supposed to go on the Linux server. But mainly I think it’s not well known, because this method is not in grub’s documentation anywhere, or on any blogs or forums.
Now this is what I like, applying simplicity to complexity!
Hope it’s useful. Test first on some non critical hard disks and enjoy!