Advertisment

Lost your Linux to Windows?

author-image
PCQ Bureau
New Update

A dual-boot setup is where you get the best of both the worlds-Windows and Linux. In such a setup, on switching on your computer, you get a choice of booting into Linux or Windows. In the latest Linux distros, such as PCQLinux 2004 (given out with PCQuest, March 2004 issue), this choice is presented graphically. Select Linux and press Enter to boot into it or select Windows. As easy as said?

Advertisment

Yes, indeed, but with a condition. Install PCQLinux (or any other Linux) after installing Windows. This is because PCQLinux installs a cool piece of software called GRUB, which sets the stage for dual boot immediately after the Linux installation. This software resides in the MBR (Master Boot Record) on the hard disk. PCQLinux installation is intelligent enough to discover the other installed OSs on your machine

and configure GRUB to show them as options to boot into. So, what will happen if you install Windows after Linux?

  • Direct

    Hit!
    Applies

    to:
    Desktop PC users with dual boot
    USP:

    Method to recover Linux multi-boot loader

    The Windows boot loader will replace GRUB and not identify the Linux installation 

  • Then, if GRUB is recovered, it will not show Windows 

So, if you install Windows after Linux, your machine will simply boot into Windows without any prompts or options, giving you the impression that Linux has disappeared. But, the fact is that only GRUB has disappeared and the Linux installation still exists on your hard disk. The remedy to the first problem (stated above) is to reinstall GRUB into the MBR. The solution to the second problem is to manually edit GRUB's configuration file to add an option to boot into Windows. The remaining article will take you through how exactly to achieve these. 

Advertisment

Recover Linux



Boot into the PCQLinux 2004 CD1. On the boot prompt (boot:) issue the following command and press Enter. 

linux rescue

When prompted to choose a language, select English. For Keyboard Type select 'us' and press Enter. Next you will be asked whether to start the network interfaces. Using tab, navigate to NO and press Enter. 

Advertisment

On the subsequent screen, Rescue, select Continue. This will search for any existing PCQLinux installation. If found, you will be informed that it has

been mounted at /mnt/sysimage. Select OK on this screen. Next, you will be taken to a shell prompt that looks as follows.

sh-2.05b#

At this prompt, issue the following command.

Advertisment

chroot /mnt/sysimage

Subsequently, issue the following command.

grub-install /dev/hda

Advertisment

This will install GRUB on the MBR of the primary master hard disk referred to as /dev/hda (see the box titled Linux's Lingo for Hard Disks and Partitions). Press Ctrl+Alt+Del at the shell prompt to reboot. 

Upon reboot, you will be able to see the GRUB screen, which will now provide the option of booting into PCQLinux. But, there may be no option for booting into Windows. Seems like a vicious circle? The next paragraph will take you through fixing this up.

Recover Windows



Now that GRUB allows you, boot into your PCQLinux installation. Next, append a couple of

lines as shown below to a file named grub.conf found in /etc directory.

Advertisment

title Windows



rootnoverify (hdX,Y)


chainloader +1

You must determine and substitute the values for X and Y. Here X stands for the hard-disk number and Y for the partition number where Windows is installed. To determine these values, switch to a Linux console or open a terminal window within X

Window. Issue the following command.

fdisk -l

Advertisment

In the output, note the Device name corresponding to the line where System is 'Win95 FAT32'. Following is a sample output of the fdisk -l command on my notebook with a dual boot setup. I installed Windows on my notebook after installing Linux.

Disk /dev/hda: 60.0 GB, 60011642880 bytes



255 heads, 63 sectors/track, 7296 cylinders


Units = cylinders of 16065 * 512 = 8225280 bytes


Device Boot Start End Blocks Id System


/dev/hda1 1 1912 15358108+ 83 Linux


/dev/hda2 1913 1977 522112+ 82 Linux swap


/dev/hda3 * 1978 4527 20482875 c Win95 FAT32 (LBA)




The line to focus on in this case is the last line. In my case, it says that Windows is installed on the primary master hard disk on partition number 3. GRUB refers to the hard disks as follows.

hda 0



hdb 1


hdc 2


hdd 3

The partition number is one less than the number (suffixed to the hard-disk name) shown by fdisk -l command. So, in my case the value of X and Y will be 0 and 2, respectively. Hence the lines to append to grub.conf will be as follows.

title Windows



rootnoverify (hd0,2)


chainloader +1

Accordingly, determine the values of X and Y in your case, append the stated lines in your grub.conf and save the file. Reboot the machine. This time GRUB will

also show you an option to boot into Windows labeled as Windows (determined by the line title

Shekhar Govindarajan



IT4Enterprise

Linux's lingo for hard disks and partitions

IDE drive partitions in Linux are referred to as :

/dev/

Unlike Windows, Linux differentiates between physical hard drives and logical partitions within physical drives. Hence, drive naming in Linux is a two-step process. First you need to know the name of the IDE device and then determine the . Depending on how your hard disk is connected to the IDE bus, the is as follows. 

Disk Device name
Primary

Master
 hda
Primary Slave hdb
Secondary Master  hdc
Secondary Slave  hdd

Let's take the example of a hard disk connected as Primary Master. Assume you have a primary partition on it (C: in Windows). If you need further drives, you have to create an extended partition and then logical partitions within it. If you have two such logical drives, they will be named as follows.

In Windows   In Linux
C: /dev/hda1
D:  /dev/hda5
E:  /dev/hda6

Note that the for logical partitions starts from 5. But why straight to 5

after 1? 

This is because though it's not possible with MS fdisk, up to four primary partitions can be created on a hard disk. It is possible to create more than one primary partition with RedHat fdisk, PDISK and Partition Magic. Hence, if they exist, they will be named as hda1, hda2, hda3 and hda4.

Advertisment