Dual Booting

Many users set up their computers to boot Slackware Linux and another operating system. We've described several typical dual boot scenarios below, in case you are having difficulty setting up your system.

Windows 9x/DOS

Setting up a computer with both Windows 9x and Linux is probably the most common dual boot scenario. There are numerous ways you can setup the booting, but this section will cover two.

Often times when setting up a dual boot system, a person will devise a perfect plan for where everything should go but mess up the installation order. It is very important to understand that operating systems need to be installed in a certain order for a dual boot setup to work. Linux always offers control over what, if anything, gets written to the Master Boot Record. Therefore, it's always advisable to install Linux last. Windows should be installed first, since it will always write its booter to the Master Boot Record.

Using LILO

Most people will want to use LILO to chose between Linux and Windows. As stated above, you should install Windows first, then Linux.

Let's say you have a 47GB IDE hard disk as the only drive in your system. Let's also say that you want to give half of that space to Windows and half of that space to Linux. This will present a problem when trying to boot Linux. I do not know the specific geometry of the drive, but chances are that 23.5GB down the drive will be well past the 1024th cylinder. A better layout for this drive would be:

 
   1GB   Windows boot (C:)
   1GB   Linux root (/)
   22.5  Windows misc (D:)
   22.5  Linux /usr (/usr)
         

You would also want to set aside an adequate amount of space for a Linux swap partition. The unwritten rule is to use twice the amount of RAM you have in disk space. A 64MB system would have 128MB of swap, and so on.

With your partitions layed out, you should proceed to install Windows. After that is set up and working, you should install Linux. The LILO installation needs special attention. You will want to select the “expert” mode for installing LILO.

Begin a new LILO configuration. You will want to install it to Master Boot Record so that it can be used to choose between the two operating systems. From the menu, add your Linux partition and add your Windows (or DOS) partition. Once that's complete, you can install LILO.

Reboot the computer. LILO should load and wait for user interaction. You can press Alt to get the boot: prompt. Type the name of the operating system you want to load (these names were selected when you setup LILO). If you forgot the name, press Tab to get a list of operating systems that you can boot.

You can configure LILO even further by editing the /etc/lilo.conf file on your Linux partition. You can set it up to display a text menu, and always present the prompt. For example, if I wanted my LILO display to do this:

   System Boot Menu
   ================
   1 - Linux
   2 - Windows

   LILO boot:

My /etc/lilo.conf file would look like this:

   # LILO configuration file

   boot = /dev/hda
   vga = normal
   message = /boot/message

   image = /vmlinuz
      root = /dev/hda2
      label = 1
      read-only

   other = /dev/hda1
      label = 2
      table = /dev/hda

And my /boot/message file would look like this:

   System Boot Menu
   ================
   1 - Linux
   2 - Windows

LILO is quite a configurable boot loader. It's not just limited to booting Linux or DOS. It can boot just about anything. The man pages for lilo(8) and lilo.conf(5) provide more detailed information.

What if LILO doesn't work? There are instances where LILO just won't work on a particular machine. Fortunately, there is another way to dual boot Linux and Windows.

Using LOADLIN

This method can be used if LILO doesn't work on your system, or if you just don't want to set up LILO. This method is also ideal for the user that reinstalls Windows often. Each time you reinstall Windows, it will overwrite the Master Boot Record, thus destroying any LILO installation. With LOADLIN, you are not subject to that problem. The biggest disadvantage is that you can only use LOADLIN to boot Linux.

With LOADLIN, you can install the operating systems in any order desired. Be careful about installing things to the Master Boot Record, you do not want to do that. LOADLIN relies on the Windows partition being bootable. So during the Slackware installation, make sure you skip the LILO setup.

After installing the operating systems, copy the lodlinX.zip (where “X” is a version number, such as “16a”) file from root's home directory to your Windows partition. Also copy your kernel image to the Windows partition. You will need to be in Linux for this to work. This example shows how to do this:

   # mkdir /win
   # mount -t vfat /dev/hda1 /win
   # mkdir /win/linux
   # cd /root
   # cp loadlin* /win/linux
   # cp /vmlinuz /win/linux
   # cd /win/linuz
   # unzip loadlin16a.zip
         

That will create a C:\LINUX directory on your Windows partition (assuming it's /dev/hda1) and copy over the necessary stuff for LOADLIN. After doing this, you will need to reboot into Windows to setup a boot menu.

Once in Windows, get to a DOS prompt. First, we need to make sure the system is set to not boot into the graphical interface.

   C:\>cd \
   C:\>attrib -r -a -s -h MSDOS.SYS
   C:\>edit MSDOS.SYS
         

Add this line to the file:

   BootGUI=0
         

Now save the file and exit the editor. Now edit C:\AUTOEXEC.BAT so we can add a boot menu. The following provides an example of what a boot menu block in AUTOEXEC.BAT would look like:

   cls
   echo System Boot Menu
   echo.
   echo 1 - Linux
   echo 2 - Windows
   echo.
   choice /c:12 "Selection? -> "
   if errorlevel 2 goto WIN
   if errorlevel 1 goto LINUX
   :LINUX
   cls
   echo "Starting Linux..."
   cd \linux
   loadlin c:\linux\vmlinuz root=/dev/hda2 ro
   goto END
   :WIN
   cls
   echo "Starting Windows..."
   win
   goto END
   :END

The key line is the one that runs LOADLIN. We tell it the kernel to load, the Linux root partition, and that we want it mounted read-only initially.

The tools for these two methods are provided with Slackware Linux. There are numerous other booters on the market, but these should work for most dual boot setups.

Windows NT

This is the second most common dual booting situation. Windows NT presents several more problems than dual booting between Windows 9x and Linux. The one we are most concerned with is if the Master Boot Record is overwritten with LILO, NT will not boot successfully. Therefore, we must use the OS Loader that comes with Windows NT. The steps below show how you should setup a Windows NT and Linux dual boot system.

  1. Install Windows NT

  2. Install Linux, making sure LILO is installed to the superblock of the Linux partition

  3. Get the first 512 bytes of the Linux root partition and store it on the Windows NT partition

  4. Edit C:\BOOT.INI under Windows NT to add a Linux option

Installing Windows NT should be fairly straightforward, as should installing Linux. From there, it gets a little more tricky. Grabbing the first 512 bytes of the Linux partition is easier than it sounds. You will need to be in Linux to accomplish this. Assuming your Linux partition is /dev/hda2, issue this command:

   # dd if=/dev/hda2 of=/tmp/bootsect.lnx bs=1 count=512
      

That's it. Now you need to copy bootsect.lnx to the Windows NT partition. Here's where we run into another problem. Linux does not have stable write support for the NTFS filesystem. If you installed Windows NT and formatted your drive as NTFS, you will need to copy this file to a FAT floppy and then read from it under Windows NT. If you formatted the Windows NT drive as FAT, you can simply mount it under Linux and copy the file over. Either way, you will want to get /tmp/bootsect.lnx from the Linux drive to C:\BOOTSECT.LNX on the Windows NT drive.

The last step is adding a menu option to the Windows NT boot menu. Under Windows NT open a command prompt.

   C:\WINNT>cd \
   C:\>attrib -r -a -s -h boot.ini
   C:\>edit boot.ini
      

Add this line to the end of the file:

   C:\bootsect.lnx="Slackware Linux"
      

Save the changes and exit the editor. When you reboot Windows NT, you will have a Linux option on the menu. Choosing it will boot into Linux.

Linux

Yes, people really do this. This is definitely the easiest dual boot scenario. You can simply use LILO and add more entries to the /etc/lilo.conf file. That's all there is to it.