Cover V10, I10

Article
Listing 1
Listing 2
Listing 3

oct2001.tar

Multi-Booting Windows 98, Linux, and SolarisTM

Brian Gollsneider

I really enjoyed Brian Wilson's article, "Using VMware as a Development Tool," in Sys Admin (March 2001). Wilson described using VMware to emulate a Windows machine running on top of a Linux box but, rephrasing his theme, it is also a technique for getting more out of your hardware. You might wonder why bother -- hardware is so cheap that you can go out and get another box for peanuts. As I write this, I find ads selling complete systems for $800, 256 MB RAM for $80, and a 30-GB hard drive for $60. It's true that hardware is dirt cheap, but I find that my most limiting factor is not dollars but space. I run out of desk space before I run out of dollars to buy machines. So, to get more out of my hardware, I use the old Linux technique of multi-booting. Sometimes you just need the native OS, or sometimes the hardware you're working with is too underpowered to handle the overhead that an emulator/virtual machine adds. In this article, I present a formula to quickly set a machine to boot Windows 98, Linux, and Intel Solaris at no cost beyond the operating systems.

Multi-booting means that you can select which operating system to run when the computer is booting up. You can access one OS at a particular time, play computer games, and then reboot into a different OS. Most OSs have some form of a boot loader, and I use Linux's LILO most of the time because of its power and flexibility. For this article, I assume that the reader can do customized installations of Windows 98, Linux, and Intel Solaris. Here are the baseline requirements for hardware -- whatever is compatible with the three OSs, CD-ROM, floppy, and 6+ GB hard drive that hasn't been partitioned. If the disk has been partitioned, you will have to follow the spirit of the various steps and make adjustments as necessary. For software, I used Windows 98, Red Hat 6.2, and Intel Solaris 8, 6/00. I have used the formula below to set up many machines to triple-boot, but there can be differences depending on how completely the hardware is supported by Solaris. Also, this is my way of doing it. There are probably others, and I welcome hearing about other techniques. The cardinal rule when doing any kind of disk partitioning is to back up your data first.

Quick summary of steps:

1. Install Windows.

2. Install Linux in an extended partition.

3. Install Solaris.

4. Fix LILO.

I'll go through the formula below and explain at the end why some of the steps are done this way. The crux of the problem is that Solaris really slices up a hard drive during installation, leaving it in a state that Linux can't handle. Using this formula, I've set up triple-boot machines in less than six hours.

Disk Partitioning 101

There are some basic things to know about how a hard drive can be partitioned, which means dividing it into different areas. Always back up your data before doing any partitioning. Each OS has a tool to partition a hard drive. Windows, Linux, and Solaris all have a tool called fdisk, although they have different capabilities and interfaces. Use the fdisk tool from the particular OS you're installing. Windows can have a primary partition and an extended partition. The extended partition can be sliced up further into smaller logical partitions. The primary partition on the first hard drive will become c:, and the other partitions will pick up drive letters according to Windows rules.

Many versions of Linux, except for the newest ones, and Solaris must have a boot partition that is below the 1023th cylinder on the hard drive. The fdisk from Linux can set up four primary partitions or three primary and one extended. Like Windows, the extended partition can be further divided. The master IDE drive on the first channel is hda. Solaris requires a primary partition during installation that it will divide into two primaries. The first partition can be divided up into slices 0 through 7, with 2 being the overlap slice that shouldn't be modified by the user. Both Linux and Solaris have very powerful fdisk tools and can specify what type each partition will be. They can even say that a partition will be for Windows.

Formula

Step 1: Installing Windows

Do a regular Windows 98 installation according to the manual. Consider the 1023 cylinder limitations for the boot manager when you are partitioning the hard drive so don't make it too big. Since the hard drive has no partitions on it, the first time you boot it up, you will run fdisk, specify a partition, and exit fdisk. You will have to reboot, then format your partition by typing format c:, and then run the Windows setup program. Windows will be on partition 1.

Step 2: Installing Linux

Further partition the hard drive. Set up the extended partition on partition 4, dividing it as you desire for the Linux installation. You need at least two logical partitions, one for / and a swap partition. Many people set up several more, /home being the most common. Do the install. Make a floppy boot disk (this is critical). You will use the boot floppy in a later step to reestablish LILO. My habit is to install Linux at the high end of the hard drive so that after the installations are complete, the partitions are in numerical order according to the cylinders. A better reason for doing this is so you can modify Linux to live above cylinder 1023. Solaris can't do that, so I put it lower on the hard drive. For this article, I assume you're using two partititions: / in 5, swap in 6.

Step 2a: Modifying Linux

Some files on Linux need to be modified before we can move onto the Solaris install. First, modify /etc/lilo.conf as root. Change the line with /dev/hda5 in it for booting Linux to /dev/hda9. See Listing 1 for a sample /etc/lilo.conf file. Next, modify /etc/fstab. The line for hda5 needs to become hda9 and the swap line from hda6 to hda10. Listing 2 shows a modified /etc/fstab file. These changes are because of the way Solaris will install. Finally, trust me on this next part. Run fdisk /dev/hda and delete the extended partition, which will also delete your / and swap partitions. This is because of the way Solaris will install. We will re-establish these partitions later, so you won't lose any data. Make sure that you record the exact start and stop cylinders of the / and swap partitions. If done correctly, the only partition visible on the hard drive right now is Windows in partition 1.

Step 3: Installing Solaris 8

Put in the Solaris installation media and boot. The Solaris installation sequence should come right up. Run fdisk to establish partition 2 for Solaris. A catch in this step is the boundary cylinders on the hard drive. Give yourself a couple of cylinders buffer between the end of the your Windows partition and where you start the Solaris partition. Also allow some buffer between the end of your Solaris partition and the start of your Linux partition. I use a rule of thumb of two cylinders on each side. If you don't add this buffer, your installation will fail. Install what you want on partition 2. Note that Solaris will divide partition 2 into partitions 2 and 3 during the install. Late in the install process, you will have a chance to look at the filesystem layout. Partition 2 will be sliced up into / in s0, swap in s1, overlap will be in s2, and /export/home in s7. These four slices are the reason that in Step 2a we added four to several lines. After the Solaris install, Linux will see hda5 as hda9. If you use more than four slices in Solaris, you will have to modify Step 2a as appropriate. Reboot. Study Listing 3 to see what the partition table looks like after the Solaris installation, especially the cylinder buffers around the Solaris partitions.

Step 4: Boot Manager

Now you have three operating systems on your computer, but you can only access Windows and Solaris. We'll fix this by configuring LILO to give you all three. First, start a Linux install again and bring it to the point of partitioning the hard drive. Use fdisk and re-establish the partitions you previously deleted. Make sure you put the exact cylinder numbers in. You will probably have an option to use disk druid but use fdisk. Disk druid is a friendly disk partitioner, but it doesn't give you the cylinder control you need right now. You will see several messages about partitions having different logical and physical beginnings. This doesn't matter to us. Save the updated disk partitions and reboot using the boot floppy you made. Type linux root=/dev/hda9 at the LILO: prompt and log in. Edit /etc/lilo.conf, adding the lines other=/dev/hda3 and label=solaris to the end of it. Then run LILO using a special option: lilo -P ignore. The -P ignore option tells LILO to ignore any partition tables that it considers corrupt, which we have because of Solaris.

Using Your Triple-Boot Machine

Now you have a machine that can run Windows, Linux, and Solaris. When you turn it on, you will see the normal BIOS prompts and finally get a prompt LILO:. If you hit the tab key quickly, you will see the different operating systems available. Type in which one you want, and hit enter. The machine will then boot as if that OS is the only one on the machine. You will have to reboot to get to a different one. Still, this approach gives you three machines in the space of one, and it is free. You have only used tools that were part of the various operating systems.

Many of the steps may look like the ravings of a madman, but once you understand the impact of the various operating systems, especially Solaris, they make more sense. It's easy to set up a system to dual boot. Windows and Linux or Windows and Solaris set up easily, provided the hardware is supported. The hard part is when you want to combine Linux and Solaris 8. As a historical note, I've been setting up machines to triple boot for years. With Solaris 7, it was easier in some regards. Linux didn't give the error messages that you see working with Solaris 8, and it stayed in one primary partition. The biggest catch was that a native Solaris partition looks like a swap partition to Linux. This normally isn't a problem, but with Red Hat 6.2 and some other distributions, you have no control over which swap space is used.

The Linux install will reformat any swap partition it finds. This means that your Solaris distribution is gone and is being used as a Linux swap space, so I hope you have a backup. With Solaris 2.7, I would install Windows, then Solaris, and then Linux. During the Linux install, I would change the partition type of Solaris to something like FAT32 and complete the install. That way, the Linux installation would leave that fake Windows partition containing Solaris alone. After I finished and rebooted, I would change it back and set up LILO to boot the three systems. Solaris 8 invalidates this trick. If you change anything about the Solaris partitions using fdisk, you mess up Solaris' boot signature and it won't come up. As a sidenote, this last statement might not be totally true. I've used Linux's fdisk to manage the partitions. Some versions of Linux also have cfdisk and sfdisk. These are more powerful and also harder to use partitioning tools. These tools might be able to reslice the partition so that Solaris still works. Since they aren't universal, I didn't explore using them. Also, Linux can't install on a disk with the type of cylinder boundary problems that Solaris 8 creates. In other words, Solaris can't be installed before Linux.

Another new catch with Solaris 8 is that it requires two partitions on the hard drive. Remember that in this setup, partition 1 is Windows, and I specified that 4 be set up as an extended partition for Linux. There can only be four partitions, so this scheme leaves 2 and 3 for Solaris. Set it up for 2, and during the install it will add 3. Summarizing, partition 1 is Windows, 2 and 3 are Solaris, and partition 4 is extended and subdivided into logical partitions for Linux. All of these are below cylinder 1023 unless your Linux distribution can overcome this problem. Finally, remember the way that Solaris subdivides partition 2 internally. This means that some boot files need to be modified by the number of slices you set up during the Solaris installation. But, when you're using fdisk, you see those Solaris slices as one partition. It's a little confusing, but you can keep track of it by remembering the way the boot process works.

Alternatives

I've also done this basic procedure on a system with two hard drives, and it's considerably simpler. I put Linux on the second hard drive by itself and tweaked the procedure. First, put Windows in partition 1 on the first drive and Solaris in partition 2, which will become 2 and 3. Then, put Linux on hdb. Since you're not going to install Linux on hda, you don't have to worry about the problematic partition table.

Conclusion

The procedure I've described will result in a machine that can boot into three different operating systems. This can save you considerable desk space in the office or a lot of weight if you're on the road. The procedure is fairly complicated but doesn't cost anything. Be careful, because messing up a step can mean that you have to back up several steps or start from the beginning to recover. Always back up your data before trying anything like this.

Brian Gollsneider is working on a PhD in Electrophysics at the University of Maryland, College Park. He can be reached at: gollsneb@glue.umd.edu.