25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Install Ubuntu Linux 9.04 on second hard drive to dual boot with Windows XP, without making permanent system changes
This set of articles documents how I installed Ubuntu 9.04 "Jaunty Jackalope" on the computer system described below. It's not a walk-through. There are quite a few of those on the net. Rather, my intent is to focus on areas where I had to make decisions based on conflicting information on other websites, explain what decisions I made and why, and describe how I resolved parts of the project that were difficult, such as modem configuration.
"Dual-booting" means installing two separate operating systems on a computer and configuring it so that at startup (boot) you can choose which one to launch.
Added for this project:
Reasons I wanted to try Linux
The Linux "bash" command set and scripting capabilities are very powerful and would allow me to efficiently do some tasks on my local PC that are quite cumbersome or even impossible in Windows. I do have Windows versions of the grep and sed (ssed) Linux utilities, but I wanted more of them... all of them! My first 13 years of computer experience were at the command line in HDOS, CP/M, and MSDOS, and I miss it. Command line utilities tend to be more flexible and work better than GUIs because all of the development time for a command line application goes into its functionality, while an excessive amount of the development time for a GUI application goes into making the GUI work.
Windows tries to protect me from the inner workings of my computer, making it more difficult to learn how it works. I understood how my old computers worked, but Windows had me convinced for years that these modern computers are so complex that I could never understand them and that only Microsoft possesses the knowledge required to make them work. I'm not so convinced of that now, and think Linux will help me get a better understanding of my PC.
The next time I buy a new computer, I might not be as enthusiastic as I was the last time about spending several hundred dollars for a new Windows operating system and Microsoft Office Professional just to keep the ability to open my old documents and databases. That might be a good time for an operating system switch. However, that's also likely to be an emergency (buying a new computer because the old one is broken), which will be a bad time to stop using Windows and start learning another operating system. In fact I almost certainly won't do that. So the time to learn Linux is NOW.
My website (this one) is on a shared Linux server at a webhost. I wanted to be able to reproduce its environment locally in order to reduce the mystery of Linux and learn how to manage the site better.
Becoming proficient at Linux usage and server management will allow me to diagnose problems on other people's servers more quickly, and maybe open the possibility of job opportunities as a Linux server administrator.
The above were reasons enough to learn more about Linux, but another question also came to mind: "Is it possible Linux is actually better than Windows?" Lots of people say it is, but many of those people really hate Microsoft's products or Microsoft the company and would gladly endure any hardship and inconvenience just to avoid them, so one cannot really trust that particular opinion of that group of people. If Linux could only be used in a walk-in freezer while wearing heavy gloves to protect against frostbite, those people would happily do it and declare through chattering teeth that it's lots better than Windows. But the fact that they're biased doesn't make them wrong. What if Linux IS better? That would be great!
Could I use Linux instead of Windows on my desktop PC and not lose capabilities I really need? I don't have an answer, but can document how I set up my Linux test in such a way that if I didn't like it, I could easily restore the computer to exactly the way it was before.
Choosing a Linux distro
There are a couple dozen most-popular Linux-based operating systems (distributions, known as distros) and many others ranging from simple to incredibly complex.
I ruled out the simplest ones, the most complex ones, and the little-known ones, which left about 5 mainstream candidates.
Ubuntu seemed a good in-between choice. It provides a LiveCD to try it out without installing anything, a simple installation process, and a graphical user interface (GUI) to ease the transition for new users, but it also provides and doesn't seem to hide the under-the-hood advanced features and configurability that I could eventually use as I learned how. It's based on the Debian distro and can use Debian's .deb packages (there are thousands available) for installing new programs. That's good for me because I'm on a dial-up internet connection and Debian's huge program library is available on DVDs, so I don't have to download them by modem.
Because I couldn't download the free 700MB disc image, I bought:
There are many websites to help choose a Linux distro. I found this questionnaire interesting and helpful, and went through it a few times with different answers to see how the recommendations changed. If you are technically inclined and familiar with the command line in any operating system, give yourself the benefit of the doubt when answering the questions. Otherwise, if your answers don't indicate that you are already a Linux expert, it will tend to recommend simple distros even if you could probably handle ones that are more complex.
Why install a new hard drive for Ubuntu?
There are two ways to install Ubuntu alongside Windows on a single hard drive.
At least wubi doesn't require repartitioning, but both methods require that you allow Ubuntu to replace the hard drive's startup program that lets you decide which operating system to launch, called the boot loader. Ubuntu will replace the boot loader installed by Windows with the GRUB boot loader, which is a change that can only be undone with a utility on the Windows System Restore CD.
Thus, both of these methods have risks, both of them assume that you will keep Ubuntu (so you can manage the GRUB bootloader), and neither of them makes it simple or easy to restore the system back to the way it was before you began. This is not Ubuntu's fault. If you install two operating systems, you must have a way to choose one at boot time, and the boot loader is the only place you can do that.
The solution for me was to install a second hard drive for Ubuntu. I could put the GRUB boot loader on that drive and boot from it to display the choice between Windows or Ubuntu. That would leave the original drive unaltered. I got this Western Digital drive. I also needed this power cable adapter because the drive requires a SATA power cable and my power supply only has "legacy" Molex power plugs.
Before installing the new drive, this is the configuration I found inside my computer: my old (and only) SATA drive was connected to the motherboard at the SATA0 plug. In my BIOS Setup/Configuration Utility (accessed by pressing F2 during boot), my old drive was configured as the first (and only) hard drive to boot from.
While installing the new drive, I changed the configuration as follows:
At this point, my new hard drive was specified as the primary boot drive, but it was unformatted. I didn't expect that to work, but it did. When the system found no boot loader there, it searched the next available device, my old hard drive, and found and used the boot loader there, so the system worked just as it did before.
There are several websites with thorough walkthroughs of the Ubuntu installation process, so I won't deal with most of that here, except to comment on two parts of the process:
One step of the installation partitions the hard drive. With two drives, I considered it important to make sure it partitioned the right one. This is not necessarily as simple as it would seem.
If there are two SATA drives, Ubuntu calls them sda and sdb, (technically /dev/sda and /dev/sdb), but how does it decide which is which? I found differing accounts on the web. Ubuntu could (and, I think, with less than full confidence, does) make the decision based on which motherboard plugs the drives are on: sda=SATA0, sdb=SATA1. But it could alternatively make the decision according to which drive is specified in BIOS as the first boot drive, a setting that does not necessarily correspond with the motherboard plug setup.
Avoiding any possible confusion was an important reason why I put the drives on the motherboard ports in their proper boot order and ALSO set that specific boot order in BIOS, so that the two would agree. (The other reason I took such care was that the first time through, I tried it without swapping the SATA0/SATA1 plugs of the two drives, and I saw in the partitioning menus that Ubuntu had got sda/sdb wrong, so I turned off the computer, swapped the plugs, and then the displays were right.)
In my case, it was easy to tell the drives apart in the partitioning menu screens because the drives are different sizes (old=160GB, new=320GB) and those sizes were displayed, but if they'd been the same size, it could have been more confusing. We're done with the sda/sdb aspect of this for the time being, but it is going to surface again later.
When reviewing the partitioning options screens, I made absolutely sure at every step of the way, on every screen, that Ubuntu had the correct drive "in mind". I chose the Manual option when it was offered, did not choose automatic or "guided" options, and inspected every screen that it offered for viewing. The partitioning went smoothly, and I did not accidentally erase my old drive.
I found at least one website that recommends avoiding trouble by disconnecting the old hard drive before doing the installation. That does make it physically impossible to damage the disk, but it has a downside.
The Ubuntu installer automatically detects the presence of the other drive (if it's connected and powered up), detects the presence of Windows, reads the other drive's boot loader, and incorporates that information into the new bootloader, automatically configuring the system for dual-boot.
However, if the other drive is hidden from it during installation, Ubuntu thinks it's the only OS on the system and that's how it configures the boot loader. I would have had to create the dual-boot configuration myself, not easy since at that point I knew nothing about GRUB. So I considered it better to leave the old drive installed but be extremely careful not to erase it by accident. Good plan!
This was the partitioning scheme I used:
GRUB bootloader installation: the return of sda vs. sdb!
The Ubuntu installer puts the boot loader on sda.
I was glad that I swapped the drive plugs to motherboard SATA0/SATA1 several steps back when I first noticed that Ubuntu had sda/sdb backwards. If I hadn't, even if the partitioning had gone smoothly (because I could manually choose the disk to partition), Ubuntu would have put the boot loader on my old 160GB drive, the wrong one.
Setting up dual-boot with GRUB
At this point I had a dual-boot system that worked! However, there were two potential problems that required configuration changes:
How to auto-reboot into the operating system that was most recently used
At every boot, I had a choice of which operating system to load. The default choice, Ubuntu, loaded automatically if I didn't choose Windows within 10 seconds. So far, so good.
However, waking from hibernation is considered a boot, so it was possible for the system to be hibernated by Windows but wake (if unattended) into Ubuntu, definitely not what I wanted. I have the Windows program BeyondTV3, which wakes the computer to do TV show recordings and then rehibernates it. To work properly, the system must auto-resume into Windows if it was hibernated by Windows.
Making the computer auto-boot into the same operating system that put it to sleep, or whichever was last-used, is made possible by manually editing (in Ubuntu) the bootloader configuration file called /boot/menu.lst (after first making a backup copy):
I made the changes shown below. The listing is incomplete and is provided to assist with understanding. I would not recommend copying and pasting. Your system is different from mine.
The default saved line says to boot in the previously saved default, instead of using an absolute entry number as the default. The old line said "default 0", which is what made the first menu choice, Ubuntu, the default in all circumstances.
The Windows section at the end of the file already had a command to savedefault, (it wasn't being used because the "default 0" setting was overriding it), but I had to add a savedefault line to the Ubuntu section, as shown.
Removing quiet and splash forces the display of system messages.
The section in green is not revised, but is interesting. It swaps the positions of the two drives and is what makes Windows believe that C: is where it always was (as the first hard drive).
# menu.lst - See: grub(8), info grub, update-grub(8) # grub-install(8), grub-floppy(8), # grub-md5-crypt, /usr/share/doc/grub # and /usr/share/doc/grub-doc/. ## default num # Set the default entry to the entry number NUM. Numbering starts from 0, and # the entry number 0 is the default if the command is not used. # EVERY TITLE LINE IN THE MENU SECTION STARTS A NEW ENTRY. WINDOWS XP HOME IS ENTRY 4, NOT 3. # # You can specify 'saved' instead of a number. In this case, the default entry # is the entry saved with the command 'savedefault'. # WARNING: If you are using dmraid do not use 'savedefault' or your # array will desync and will not let you boot your system.
(...long unmodified section omitted...)
## ## End Default Options ## title Ubuntu 9.04, kernel 2.6.28-11-generic uuid aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa kernel /boot/vmlinuz-2.6.28-11-generic root=UUID=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa ro
Excessive time needed to boot, with a lot of disk activity. Occasional boot into the wrong OS.
I'm revising this section in 2011, two years after the initial installation. The dual-boot setup was never completely trouble-free until recently, when I finally stumbled across the cause of the problem and was able to fix it.
The problem: the first part of booting (before the GRUB operating system menu appeared) sometimes (about 1 in 20 boots) took nearly a minute, during which the hard drive indicator light was continuously lit but the drive didn't seem to be doing much (no sounds). Then, the GRUB selection menu would get bypassed, and the system would automatically boot into Windows even if Ubuntu was the last-used OS. The system seemed to be ignoring GRUB.
Over the years, I tried the following solutions:
1) (2009) In my BIOS Setup Utility, I discovered that Silent Boot was set to On. This meant that during boot, instead of displaying diagnostic messages, BIOS would show a Gateway logo image. However, the location of the image was not specified in BIOS Setup Utility, so I speculated that it was specified in the boot loader code on the old drive, and BIOS couldn't find it because the old drive wasn't the boot drive anymore. So I turned Silent Boot Off. I thought the problem was solved, but it wasn't, although I still prefer seeing the diagnostic messages rather than the logo.
2) (2011) The actual problem was that BIOS was taking shortcuts, trying to boot so fast that my first-boot hard drive occasionally wasn't ready and wasn't detected, so BIOS switched to the next boot option, my Windows hard drive with its Windows-only bootloader. The following two BIOS settings finally did solve that problem:
Restoring the system to Windows-only
Based on my initial impressions of Ubuntu and Linux, I doubt I will do this, but to restore the system to Windows-only use, I can easily swap the drive plugs at SATA0/SATA1 on the motherboard to put C: back on SATA0, and configure BIOS to give it first boot priority. Its boot loader would once again be used, and the boot loader on the new drive would be ignored. The new drive would become a secondary data drive to use however I wanted, and the system would be exactly the way it was before.
Next: Setting up the modem
Questions and comments are welcome in the discussion forum.
Copyright ©2012 Steven Whitney. Last modified Sun 07/29/2012 10:56:21 -0700.