Wednesday 22 May 2013

Dual Boot - Debian 6 and Windows 7


My main purpose in installing Linux (this time) is so that I can experiment with it in conjunction with my Raspberry Pi. And since my new favourite toy is running the Raspbian OS I chose to install Debian, the distribution of Linux that Raspbian is based on. Having the full up Debian distro on my desktop will give me access to the software and support community surrounding Debian as well as the quickly growing Raspbian community.

For full and detailed install instructions for Debian you can refer to the installation manual.

I deviated from the typical install method for Debian in three important ways. First, I intend to dual boot Debian on a machine that already has Windows installed. Second, I used Logical Volume Manager (LVM) to create my own partitions for my installation. Third, I kept my Windows boot-loader intact so that if my Debian install fails it will automatically boot into the Windows OS and vice versa.

First I'll say a little bit about my desktop system and how it was setup before Debian. I am using Windows 7 x64 and I have two hard drives installed. The first drive (the newer of the two) is a SATA II with 500 GB capacity, the second drive (the older) is a PATA IDE  drive with 200GB capacity. The PATA drive was set-up as the first boot device and contains all of my operating system files including the Windows boot manager on the master boot record (MBR). The SATA drive was already divided into two partitions, the first partition which is approximately 50 GB is now housing Debian; the second partition already contains data and is formatted with NTFS.

Before making any changes, I made sure that my current project data was backed up on my NAS and carefully checked all my drive information. It’s a good idea to write down the actual disk sizes and other identifying information for each of your current partitions and drives; this can be used as an extra check before you make changes. If your process ever involves changing boot order or using different disk utilities drive labels can change and it’s always good to have more than one way to check which volume you're really looking at; taking lots of notes throughout the process is always a good idea too.

To start with my install, I used EASEUS Partition Manager (free for personal use) and deleted the first partition on my SATA drive (~50GB). After this I restarted my PC with the Debian install CD in my DVDROM drive and chose the Graphical Install option. The first few steps when using the installation wizard involves a number  of locale and network settings. Eventually we come to the Partition Disks section of the wizard. I needed to use the Manual option as I wanted to keep my second disk partition intact; I also chose the ‘Manual’ option because I wanted to learn more about server configuration and logical volume management (LVM). One of the particularly useful features of the LVM is that you can combine multiple disks (physical volumes) to make one large space and logical volume group (LVG) and then create as many smaller partitions within it (logical volumes) as you like, this is very useful for servers and RAID volumes.


If you want to learn more about LVM there is a great guide here. One thing to note, is that you need to double click to select options as you proceed through the LVM and partitioning section of the wizard.

Okay, double clicking all the way, I chose Manual and then Configure the Logical Volume Manager and create a logical volume group. I named my group 'lvg1' and selected the physical volume where the LVG would reside, for me this was the free space on the first drive as I had deleted the original partition there. After making all of these selections I can write my changes to disk and this leaves my current drive and partition configuration as shown below.

This view was generated by running the fdisk shell command (fdisk -l). As you can see 'sdb1' is my first boot device with Windows installed (~200GB) and 'sda1' is an extended partition now housing 'sda2' which is my Linux LVM partition.

After creating the LVG I wrote these changes to the disk and displayed the configuration to verify my settings.

Next, by double-clicking on the LVG you get options for creating your logical volumes; I created three volumes and wrote the changes to disk. I then configured these volumes by double-clicking on them and choosing file systems and mount points. These are the configuration settings I chose:

LV Name Size File System Mount Point
vol1 150MB EXT2 /boot
vol2 3GB swap
vol3 >Free Space EXT4 /root

Once you've chosen a mount point for root ‘/’ and written these changes to disk it should begin the rest of the install process automatically. If you want to look at the logical volume partition information after you are done you can use LVM commands from the command line. I used root terminal from within the desktop GUI to examine my partition information. Shown below are the commands I used in the terminal window and the partition information displayed.

For information about the volume group use vgdisplay


For volume information use lvdisplay

When I got to the boot-loader installation stage (Grub2 is installed), I let it install on the master boot record (MBR) of the first drive (labeled sda) which is the default option. Because of my drive configuration this is not the first boot device or the drive which contains Windows so the windows boot-loader does NOT get overwritten. During the install process Grub automatically recognizes my previous windows install and configures itself appropriately, allowing me to choose between the two operating systems when the system boots.

One final step, in order for Grub to work it needs to be on the first boot device. So I have to change the boot order by entering your motherboard's BIOS and changing the device boot order. For my motherboard this involves restarting the computer and then tapping delete key when the Asus logo screen comes up. This is a common method for entering the BIOS for many motherboards (the F10 or F8 keys are also common), you need to check your motherboard model documentation for this information. I need to set my SATA hard drive (sda) to boot first; so I changed my boot order to 1) Debian disk (sda), 2) Windows disk (sdb) and 3) DVDROM drive. In this configuration if an OS is not found on the boot device, it is skipped and the next one is tried. With my windows boot-loader intact it becomes my fail-safe OS.

With that completed the Grub OS menu now presents itself on restart and I can choose from Debian, Debian (safe mode) and Windows 7.

No comments:

Post a Comment