My boot configurations

Here I discuss the setup for dual booting (or multi-booting) with Windows and linux.  This post discusses the choices and my practices and preferences.

As previously discussed, booting a system depends on the operating system having its own loader and on the partition boot record (PBR) for that operating system.  For multi-booting, it is useful to also have some sort of boot manager function that presents you with a menu during bootup, so that you can choose which of your systems to boot.

Typical linux installs use grub as the system loader.  And grub has a built-in boot manager function which handles the task of choosing which system to boot.  If lilo (linux loader) is used to load linux, that also has a built-in boot manager function.  The windows loader also has a built-in boot manager function, and using that for selecting the operating system is a choice some might prefer.

Another option is to install a separate stand-alone boot manager.  During the heyday of OS/2, I used the OS/2 boot manager for selecting which system to boot.  It worked rather well.  There are other boot managers available today — a web search for “boot manager” will turn up several.

Booting linux

To boot linux, you will have installed a boot loader such as grub or lilo, which already has a built-in boot manager.  For this to work, code to load the linux loader must be installed in either the MBR (main boot record) or in the PBR (partition boot record) of a primary partition.

If your linux install uses a primary partition on the first hard drive, then you can install grub or lilo to boot from there.  This is what I prefer to do if possible.  One way to do this is to create a separate partition for “/boot” and use that.  The “/boot” partition need not be very large.  On my current desktop, it is around 100 MB.  That computer came with an OEM partition (a Dell partition).  I decided that I didn’t really need that, so I reused that partition for “/boot”.  The openSUSE install defaulted to choosing that partition for booting.

When I first installed linux on my laptop, I decided to not take over the OEM partition.  So that left me with linux installed entirely in logical drives.  The installer, in that case, defaulted to installing its PBR code in the extended partition.  That’s not ideal, but it does actually work rather well.

The other choice, with linux installed entirely in logical drives, is to install the boot code in the MBR.  There are some advantages to this.  In particular, it will work independent of which partition is marked as active.  And you can use boot loader options in grub or lilo, that mark the partition you are booting as active.  When I was using solaris 8 as one of my multiple operating systems, I put lilo in the MBR because the solaris partition needed to be marked active for it to boot properly.

There’s also a downside to installing the boot code in the MBR.  And that is, that any install or repair of another operating system is likely to overwrite the MBR, making your boot manager inaccessible.  This is part of why I prefer to use a small “/boot” primary partition for booting linux.

Booting Windows

To boot Windows, it needs to be installed partly in a primary partition, and it boots from that.  With Vista or Windows 7, usually two partitions are used for the install.  There will be the main partition and a recovery partition.  The recovery partition is the smaller of the two.  Windows can boot from either.  However, if you use the Windows BitLocker software to encrypt your Windows partition, then it will need to boot from the recovery partition.

Using encryption

If you use the BitLocker encryption for Windows, then you will need to boot Windows from the recovery partition.  This is because everything in the main Windows partition will be encrypted, so unusable until decrypted.  The recovery partition remains unencrypted, and can thus be booted.  It sets up automatic decryption/encryption of data as read from/written to disk, so that the encryption is transparent once the system has been booted.

With linux, using LUKS encryption, nothing special needs to be done if you are only encrypting the “/home” partition and/or the swap partition.  But if you want the root partition to be encrypted, then you will need a separate “/boot” partition.  That way the system can be booted and automatic decryption/encryption setup before accessing the encrypted root file system.

The boot manager

If you are using grub or lilo to boot your linux system, then it will be setup as a boot manager as part of the install.  The way it works, is that if you want to boot Windows then it will load the PBR for the windows partition onto memory, and jump to the boot code in that loaded PBR.

In a normal Windows install, the Windows boot manager is set to only boot Windows.  If you want it to boot another system, then you must set it up to do that.  I’ll discuss how to do that in a separate post.

My current setup

At present, I am using a separate “/boot” for booting grub.  I have also setup the Windows boot manager, so that it can boot linux as well as Windows.  That way, if the linux “/boot” partition is marked as active, then I can use the grub boot manager for selecting linux or Windows.  If the Windows partition is marked as active, then I can use the Windows boot manager for getting into my grub boot manager.  It’s a kind of fail-safe arrangement.  When installing a Windows service pack, I first set the Windows partition as active.  Experience has shown me that Windows service packs can sometimes fail if the Windows partition is not active.  After installing the service pack, I can still get to the grub menu via the Windows boot manager.

In practice, I currently have the Windows partition marked as active, with it set to boot to Windows by default.  There are two reasons that I do this:

  1. There are other members of the family who are not linux users.  So this setup allows them to boot the system without having to know how to negotiate a grub screen.
  2. I am using encryption with linux, but not with Windows.  So Windows can boot unattended, while booting linux requires entering the encryption key.  It seems to make sense to me, that the default boot should be to the system that can boot unattended.

Possible problems

The main problem that people run into, is that the active partition is changed so that they no longer get into their preferred boot manager.  I have already described how I avoid that, by setting up booting to the grub menu from the Windows boot manager.  However, if you did not setup the Windows boot manager, all is not lost.  Simply boot from a live linux CD or boot the install DVD to rescue mode.  Then get into linux “fdisk” and change the active partition.  In my case, the steps would be these:

# fdisk /dev/sda
p  ### display the current partition table
a
3  ### turn off the active bit for partition 3 (Windows)
a
1  ### turn on the active bit for "/boot"
p  ### display the modified partition table for visual checking
w  ### write the results and quit

The “###” and following text on those lines are comments, and should not be included.

The other problem that you can run into, is if you installed grub or lilo in the MBR, and the MBR boot code has been wiped out when installing or updating another operating system.  If you were wise, you kept a copy of the MBR elsewhere, and you could write back 440 bytes from that copy.  Otherwise you will have to go to rescue mode and reinstall grub and/or lilo.

Advertisements

Tags: ,

About Neil Rickert

Retired mathematician and computer scientist who dabbles in cognitive science.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: