Sunday, November 18, 2007

Boot Ubuntu from Floppy/ Fix Windows MBR

If you live in a Windows only household with non-technical users and you have been held back from doing a dual install Linux/ Windows system by the fact that most Linux OS's, and Ubuntu in particular, changes the boot process thereby causing a potential uproar in the house, then this blog is for you! Faced with this situation I found by combining instructions from several different sources and simple head exploding trial and error how to create a system with Ubuntu and Windows that maintains the Windows boot process and uses a floppy to boot into Ubuntu and a frugal install of Puppy Linux 301 - 3 OS's to choose from!

This blog is part 2 of my previous blog which details how to install Ubuntu as a second OS using GParted to manually create partitions. However, it is applicable in any situation that uses GRUB as a bootloader, since essentially I am just putting the Windows MBR back and running GRUB from a floppy. In addition to having Ubuntu already installed you will also need mbrfix, a very useful little Windows utility that can be placed on a floppy and used to fix the MBR. Detailed instructions are provided with the program.

So we start from the install of Ubuntu in addition to XP which has GRUB loaded at boot. Boot into Ubuntu (or just let it do so automatically) and follow the instructions to make a GRUB boot floppy (taken from here):

To keep from having to type sudo over and over, in the terminal type:

sudo -s

and enter your password. Now format the floppy:

mke2fs /dev/fd0

Now mount the floppy and copy the necessary files:

mount /dev/fd0 /media/floppy (note: there is a space between fd0 and /media)
mkdir /media/floppy/boot
mkdir /media/floppy/boot/grub
cd /boot/grub
cp stage1 stage2 menu.lst /media/floppy/boot/grub
umount /dev/fd0

Now start GRUB in interactive mode by typing


and the command prompt should change to 'grub>' after which you type the following commands:

device (fd0) /dev/fd0
root (fd0) (note - I get an error message the first time I type this but it works fine if I repeat it)
setup (fd0)

Now you have a bootable floppy. However, this did not work for me without a couple of extra steps.

Restart and boot from the floppy. You should see a screen exactly like you were booting from the hard drive, with a list of OS's and Windows XP at the bottom. Choose the Ubuntu and if it starts then you are good to go. However, I always got an 'error 15 file not found' message. Press any key to continue and then 'c' to go to the command line. Type

find /boot/grub/stage1

one line of output should be the disk - fd(0) - and the other is the partition that your Ubuntu is on, something like (hd0,5); make a note of this for later.

Now take out the disk and poweroff with the power button and then reboot into Ubuntu. Put the floppy back in and open up a terminal and type

sudo -s
mount /dev/fd0 /media/floppy
gedit /media/floppy/boot/grub/menu.lst

This opens up the menu.lst document in the default editor as root, allowing you to make changes. Scroll down to the sections that don't start with #. You'll notice the titles are all the same as those listed on your initial screen when you use GRUB to boot. The first section is the one that you default boot from. Delete the last two lines of the first section:


and then Save. This should alter the menu.lst document on the floppy. To make sure close the terminal, go into the /media/floppy/boot/grub folder from the Places menu and open the menu.lst file by double clicking on it and making sure those two lines are missing.

Now reboot with the floppy in and Viola! it should boot into Ubuntu as if you were booting from the hard drive/ MBR-GRUB.

Finally, reboot into Windows. Run mbrfix.exe in the commandline to replace GRUB with Windows' standard boot code by opening the command window and typing:

Mbrfix /drive 0 fixmbr /yes

This will replace GRUB with the standard Windows Boot code. Now when you boot you will go straight into Windows and the only way to access your Ubuntu/ other linux distros is with the floppy. You now have a hidden Ubuntu OS, since the linux partitions are not visible to Windows without special software.

No comments: