Separate OS, separate drive

Q I would like to install Ubuntu on a separate SATA drive from the current SATA drive that has Windows XP. After doing some research on this, the installation process seems fairly straight forward. My one big question has been with the installation of Grub. Is it possible to install Grub on the Ubuntu drive only and keep the XP drive untouched?

A Yes it is possible, but not necessarily the best option. If you install Grub into the master boot record of the Windows disk, it will not touch the partition containing your Windows install. The Ubuntu installer will take care of this and create a boot menu with options to use Windows or Ubuntu. The only drawback of this is that it will fail to boot if you remove the Ubuntu disk, which is easily remedied by running fixmbr from the Windows rescue CD. If you want to keep the bootloaders separate, you have a couple of options. You could install to the Ubuntu drive's MBR and use your BIOS's boot menu to choose which drive to boot.

Most motherboards now pop up a menu if you hold down a key while they boot; see the initial BIOS screen or the manual to see which key. This has the advantage that it doesn't touch your Windows disk at all, but you have to be quick to hit the menu key at the right time. The alternative is to modify the Windows bootloader to add an option to pass control to Grub on the other disk. Install Ubuntu by booting from the disc and running the installer, telling it to use the second disk in the partitioning window. hen the 'Ready To Install' window is displayed, press the Advanced button and set the device for bootloader installation to /dev/sdb, the second disk. You also need to take this step if you want to use the BIOS boot menu to choose between disks.

Now let the install run but do not reboot at the end (if you do, you will not have an option to use Ubuntu and will need to boot from the install disc again for the next steps). Open a terminal (Applications > Accessories > Terminal), switch to the root user and mount your Windows filesystem with

sudo -i
mkdir /mnt/windows
mount /dev/sda1 /mnt/windows

Then create a file on there containing the bootloader code from your Ubuntu install with

dd if=/dev/sdb of=/mnt/windows/ubuntu.img
bs=512 count=1

This creates a file called ubuntu.img (the name is unimportant) that contains the first 512 bytes of the second disk, with the Ubuntu bootloader. Now reboot into Windows and edit C:\boot.ini in something like Notepad to add this line to the end

C:\ubuntu.img="Ubuntu"

You could edit this file in Ubuntu, but Windows uses different line endings from Linux and ntldr can be a bit fussy, so play safe and subject yourself to Notepad. Reboot again and the Windows bootloader should show you a menu with options to boot Windows or Linux.

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar