Dual Boot Windows 7 & Debian 6.0

Purpose

This tutorial will instruct how to configure a PC to dual boot between Windows 7 and Debian 6.0 with the use of the Grub Boot Loader 2. A single hard disk drive will be used for the example.

This tutorial will also instruct on repairing the GRUB2 loader if a new Windows install is performed which automatically replaces the MBR (Master Boot Record) as part of the normal Windows install..

As Built for this tutorial

Dual Boot PC

Hardware

Dell Core2Duo 2.6Ghz, 4GB RAM, 640GB HDD

Operating System

Debian 6.0 (Squeeze)

Operating System

Microsoft Windows 7 PRO

For this tutorial I will assume that Windows 7 was already installed. But with a simple manipulation of these processes the reverse could also be achieved.

Method

A partition with adequate room is required for the Debian installation. A partition can be resized in order to make a spare partition available. The size of the new partition will need to be appropriate to your requirements. As a guide the base Windows 7 PRO installation uses approx 7GB of hard drive space whereas Debian 6.0 Desktop uses approximately 3.5GB.

Install Debian in the spare partition as per your requirements. Since Debian has now replaced the MBR (Master Boot Record) Windows will need to be added to the GRUB boot menu so it is still available.

The Windows partition will need to be identified in order to create the menu item. This can be done by checking fdisk list output.

fdisk –l

The output should look something similar to the below. In my case the Windows partition was sda1.

Now that the Windows partition has been identified create file /etc/grub.d/09_Windows7PRO with the following contents amended to suite. Note! The numbers at the front of the file name depicts the order in which the files will be run and therefore also the order in which the menu items will appear. In my case the Debian file was 10_linux. I wanted Windows to be the default so I needed the entry to appear first on the Grub menu hence 09_Windows...

In the above script the menu entry field can be modified to whatever you want to appear in the menu. The set root=(hd0,?) needs to be set to reflect the windows boot partition.
e.g.
/dev/sda1 = …root=(hd0,1)
/dev/sda5 = …root=(hd0,5)

Give the new script execute permissions

chmod a+x /etc/grub.d/09_Windows7PRO

To make things a little nicer and less automated I decided to remove the os-prober application from my Debian installation. (I don’t like the format that os-prober uses)

You should now be able to boot either Debian or the default Windows 7 Installations.

If you want to be really lazy!!!!

If the os-prober application is installed you should be able to just run the update-grub2 command and have a Windows entry added to the bottom without having to go through all the above steps. Not as nice though I say. Plus it identified the Windows 7 install as Vista in the menu and placed it last in the list. (Talk about insult on top of insult)

Grub Repairs

Let’s say you had the dual boot running all well and good then you go and re install windows. Guess what? That’s right Windows have replaced Grub MBR with its own so now you have no access to you Debian system. Well there is no need to reinstall Debian which will lose all you good setup. We just need to re install Grub.

Boot PC from “debian-live-6.0.1-i386-gnome-desktop” or “debian-live-6.0.0-i386-standard”.

Note! If non GUI Live Debian CD is used then you will need to switch to root user via the command sudo su

Grub will need to be installed. During the installation just <ENTER> through the option screens and select YES “Continue without installing GRUB.