HostOnNet Blog

Lost your Linux to Windows?

Looking for Linux Server Admin or WordPress Expert? We can help.

Lost your Linux to Windows?

A dual-boot setup is where you get both Windows and Linux.

Multiboot is done with software called GRUB. This software resides in the MBR (Master Boot Record) on the hard disk. Linux installation discover the other installed OSs on your machine and configure GRUB to show them as options to boot into.

What will happen if you install Windows after Linux?

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. 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.

Recover Linux

Boot with Linux 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.

On the subsequent screen, Rescue, select Continue. This will search for any existing Linux 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.


At this prompt, issue the following command.

chroot /mnt/sysimage

Subsequently, issue the following command.

grub-install /dev/hda

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 Linux. But, there may be no option for booting into Windows. Next we will fixing this up.

Recover Windows

Now that GRUB allows you, boot into your Linux installation. Next, append a couple of lines as shown below to a file named grub.conf found in /etc directory.

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

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 ingrub.conf).

Posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.