6.3. Dual Boots Can Be TroublesomeMost Linux systems actually offer multiple boot options. The most common dual-boot configuration allows you to boot either Linux or Microsoft Windows. And in fact, most modern Linux distributions automatically detect a pre-existing Windows operating system during the installation process. The Windows partition is left alone, and the installation program adds a stanza to the bootloader to facilitate booting into Windows. You don't have to have a second operating system to have a dual boot. If you've installed new kernels from an RPM or DEB package, it has set up alternate kernel selections in GRUB or LILO. Alternatively, if you installed a new kernel from a tarball, you need to know how to configure a new kernel selection in your bootloader. In this annoyance, I'll show you the basics of configuring a dual boot for multiple Linux kernels, as well as a configuring a dual boot on GRUB and LILO for Linux and Microsoft Windows. This annoyance provides fundamental bootloader basics for the one that follows. 6.3.1. Configuring a Linux Kernel Dual BootIf you have just configured a new Linux kernel, you'll want to be able to boot both the old and the new kernel. At least until you've completely tested the new kernel, you need access to the old one just in case something goes wrong. If you install (not upgrade) a Linux kernel from a modern RPM or DEB package, the process automatically adds the new kernel to your current bootloader. If you're using a distribution with one of these systems, you generally should use the kernels as compiled by the distribution company. This helps make sure that drivers get to the right directories. In addition, Red Hat (and others) often include "backports" from more advanced kernels, especially in its enterprise series of distributions.
However, if you want the latest in functionality, you may need to use the latest kernel, in tarball format, from http://www.kernel.org or one of its mirrors. When you unpack and compile the kernel from the source code, it does not automatically upgrade your bootloader, so you'll need to upgrade it yourself. For more information, see "The Kernel Needs an Upgrade" in Chapter 7. Fortunately, GRUB and LILO stanzas associated with the former kernel can help. Generally, all you need to do is modify the version numbers associated with the kernel and initial RAM disk. For example, if you've upgraded from a Debian 2.6.8-1-386 kernel to a kernel.org 2.6.11 kernel, you'll need to set up another stanza in your bootloader. When you compile a new kernel, it's useful to modify the EXtrAVERSION variable in the Makefile, which you can find linked from the /usr/src/linux or /usr/src/linux-2.6 directories.
For instance, if you set: EXTRAVERSION=-new before you compile a kernel, you'll get a file with a name such as vmlinuz-2.6.11-new. Take a kernel with the following stanza in a GRUB configuration file: title Debian GNU/Linux, kernel 2.6.8-1-386 root hd(0,5) kernel /vmlinuz-2.6.8-1-386 root=/dev/hda7 ro initrd /initrd.img-2.6.8-1-386 savedefault boot After you've compiled the new kernel from source and created an associated Initial RAM disk, you can set up a new stanza for that kernel. I'm assuming that you're storing the kernel and Initial RAM disk files in the standard location, /boot. The new stanza would look almost identical to the previous stanza: title Debian GNU/Linux, kernel 2.6.11-new root hd(0,5) kernel /vmlinuz-2.6.11-new root=/dev/hda7 ro initrd /initrd.img-2.6.11-new savedefault boot Generally, if you've created a new kernel, you should create a new Initial RAM disk using the new kernel version number. For example, if your new kernel is vmlinuz-2.6.11-new, you'd use the following command: mkinitrd 2.6.11-new The changes in a LILO configuration file follow the same pattern, and the modifications are elementary. 6.3.2. Configuring a Dual Boot with Microsoft WindowsThere are several annoying reasons why you might have to rebuild GRUB or LILO in a dual-boot configuration. A junior administrator might have deleted the file. Hard drive corruption might have made the file unusable. Someone else might have edited the bootloader incorrectly.
Fortunately, the Linux bootloader directives associated with Microsoft Windows are fairly simple. If you need to set up Microsoft Windows in a dual boot, you need to know the partition with the basic Microsoft Windows system filesystem. If you're in Linux, you can make a good guess with an fdisk -l command. That will show the partitions with Microsoft-based filesystems. Some examples include: Device Boot Start End Blocks Id System /dev/hda1 * 1 20012 10929039+ 7 HPFS/NTFS /dev/hda2 20012 77520 30453674+ f W95 Ext'd (LBA) /dev/hda5 20012 40024 10929039+ c W95 FAT32 (LBA) fdisk recognizes the format of each partition and displays it in the final column. Yes, the System label associated with the first partition is vague. HPFS is short for the High Performance File System, which is associated with IBM's OS/2 operating system. I don't have one of these operating systems available, so I haven't tested it. But as it's designed for partitions of 200400 MB and can't be read by Windows NT 4 and above, you're unlikely to encounter it today. The alternative is NTFS, Microsoft's New Technology File System. Linux's fdisk does not distinguish between Microsoft's NTFS standards, which have changed as Microsoft operating systems have evolved from NT 4 to 2000 and then XP/2003. A simple GRUB stanza for Windows begins with a title, which can specify anything you'd like to jog your memory: title Windows Because the first partition is bootable, it should contain an operating system. In GRUB, this can be associated with the following directive. While it points to the first partition on the first IDE hard drive, it does not attempt to mount it in a Linux fashion: rootnoverify (hd0,0) A GRUB pointer to a Microsoft operating system requires one more directive. The chainloader directive points to the first sector (+1) of the noted partition, from where just about any operating system continues the boot process: chainloader +1 The results are straightforward. A typical GRUB stanza for a Microsoft Windows operating system is: title Windows NT/2000/XP root (hd0,0) chainloader +1 A LILO stanza for Windows also contains a line for a title, such as: label = Windows To specify the bootable partition containing Windows, you need two directives. The first indicates you're booting a non-Linux operating system located on the /dev/hda1 partition, and the second keeps LILO from looking for a Linux boot image: other=/dev/hda1 optional All together, a typical LILO stanza pointing to a Microsoft Windows operating system looks like: other=/dev/hda1 optional label = Windows 6.3.3. Other BootloadersThere are other commercial bootloaders that can load Linux on a computer. Some aren't directly related to any operating system. The leaders in this area include Partition Magic (http://www.symantec.com/partitionmagic) and Partition Commander (http://www.v-com.com). The alternative is to boot Linux with the Microsoft Windows bootloader, NTLDR. If you want to use NTLDR, most documents strongly recommend that you do so with a boot disk. In NTLDR, the basic menu is associated with the C:\boot.ini file. Normally, it includes commands such as: [boot loader] timeout=5 default=multi(0)disk(0)rdisk(0)partition(1)\WINNT [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows XP Professional" /fastdetect /NoExecute=OptIn If you're familiar with Linux bootloaders, you may recognize the basic format of this file. Essentially, these commands boot Microsoft Windows XP Professional from the first IDE hard disk, after a five-second delay. To configure a pointer to Linux, you need two things. First, add the following line to boot.ini: c:\linux.bin="Linux" Next, create a linux.bin file. One method of doing so is with a disk dump from the /boot partition. For example, if /dev/hda7 is mounted on /boot, you can create linux.bin with the following command: dd if=/dev/hda7 of=linux.bin Then copy linux.bin to the partition associated with the Microsoft C: directory on your hard drive. Just remember, Linux bootloaders are designed for multiboot environments, especially with Microsoft Windows. NTLDR is not. You're less likely to be annoyed if you use GRUB or LILO. |