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.

Monday, November 12, 2007

Using Windows Partitions/Drives in a Linux OS

How to use Windows XP Filesystem in Linux (Kubuntu 7.04 Feisty Fawn)

This is probably the most basic thing to learn if you want to get started using Ubuntu in a dual boot system. If you are having trouble with things like storing documents on a drive that was formatted under Windows or playing music from your Windows drive this will most likely solve your problem. I should have written this down before because it always bites me in the rear when I do a new install and I pull my hair out thinking it is something more complex than it is.

A brief overview of file systems. Your computer stores and retrieves information from a medium like a hard drive or disk using a predefined system of dealing with data, ie a file system. The default system for XP and Vista is NTFS. The default for most Linux Operating Systems is Ext3, and sometimes Ext2. They are pretty much mutually exclusive - Windows does not even acknowledge the existence of an ext3 formatted drive (shows up as unformatted) without special software, and until recently Linux OS's could only read from NTFS and not write to it (ie save stuff to it).

Enter NTFS-3g, a development that has really made dual boot systems usable because it allows a Linux OS to read and write to NTFS so that you can share disk space between Windows and Linux. Therefore you can put music on an NTFS partition and play it from both a Linux and Windows OS, or movies, or pdf files, or whatever.

These instructions are specific to Kubuntu 7.04 but they can be easily tweaked to be used under any Linux OS that uses ntfs-3g.

Install the necessary utilities. In a terminal type:

sudo apt-get install ntfs-config

This will also install a gui that allows you to different choices - you can get specific instructions here(Skip down to the Configuration section).

To see exactly what partitions are available to me I use GParted Partition Manager under Start>System>GNOME Partition Editor, which I describe using in more detail in my blog about setting up a dual boot system. This shows exactly which partitions are there and what file system they are using. This is especially useful if you have two hard drives because it seems Ubuntu only automatically recognizes partitions on the one that it is installed on (hda or sda). Make a note of all the ntfs drives by the name they are associated with - ie sda1 or sda7 or hdb3 (I'll use these as examples earlier). Next you can go to /media and see if those drives are there. If they are you can see if they are mounted by clicking on them and seeing if any files show up. If they are not, ie there are no folders or icons marked hdb3, then open a terminal and type

sudo mkdir /media/hdb3

and one will magically appear!

Now to mount your ntfs drive. BTW 'mount' is linux/unix terminology for making a drive available, so although a drive will show up in GParted, usually as /dev/hdb(N), you cannot access the drive until it is mounted. Mounting a drive transfers the files on the drive to a folder that you can then access. The folder is usually in /mnt or, as in Ubuntu, /media. The command to do this is as follows:

sudo mount -t ntfs-3g /dev/hdb3 /media/hdb3

This will now allow access to the files on /dev/hdb3 to be accessed by clicking on /media/hdb3.

To automatically mount the drives on system start up you can install the automatix package manager and use their tool for automatically mounting ntfs and fat32 drives.

Learning to use Linux is well worth the time and challenge. I recommend using a virtual machine first but moving on to a dual boot system and using Linux with the full power of your machine. I am not one of those people hell bent on taking down Microsoft but I do think it is fun and worth the time to explore different options.

UPDATE (5-12-2008) I now think it is much better to edit the /etc/fstab file, both from a functional standpoint and from a learning perspective. Here is an excellent and informative post. I used the ntfs-config tool initially and then edited the script that generated which led me to the realization that putting tabbed spaces in the script to make everything look pretty was what was causing it to not work for me initially! Gparted was very helpful as well. There seem to be some issues with Automatix being potentially dangerous as well. Here is a very informative blog outlining problems with Automatix.