This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature

Convert a Windows system to dual-boot Linux on a second drive

By Philip J. Hollenback on February 21, 2005 (8:00:00 AM)

Share    Print    Comments   

I was recently assigned the task of converting a system running Windows XP to dual-boot Windows and Linux. The user needed to run Windows most of the time, but occasionally needed to boot Linux to run special applications. The one overriding requirement was to change the existing Windows setup as little as possible. In this case, that meant adding a second hard drive. Easy enough, right? Well, not so fast.

The computer in question was a standard white-box PC with Windows XP installed on its one hard drive. One option was to shrink the exiting Windows partition with NTFSresize and install Linux in the resulting free space. However, this was too intrusive. I did not have a backup of the data on the Windows machine, and didn't want to take the time to make one, so I was loath to do anything that could wipe it out.

So I installed and set up a new second drive, then installed Fedora Core 3 in the standard manner. When the installer asked what drive to use, I chose the second IDE drive, hdb. The other key step was to make sure the installer did not install a Linux boot loader on the primary hard drive. While having the installed do this is generally the recommended method of installing a dual-boot Linux/Windows system, I didn't want to do it because of my goal of minimizing changes to the Windows disk.

The Windows bootloader (NTLDR) can be configured to boot Linux partitions, so I decided to use it as the primary bootloader. The default boot option would remain Windows, so if the user took no action on boot, the system would go to Windows as it always had. However, if the user selected Linux in the NTLDR boot menu, it would hand off to the Linux bootloader (GRUB) on the second drive.

The Fedora installer gives you the option of placing GRUB in the master partition of the primary IDE drive (hda) or in the boot partition of the secondary IDE drive (hdb1). I instructed the installer to take the second option. Note that without extra configuration later, this setup will not boot to Linux, because whatever bootloader is on the primary drive -- in this case Windows -- will always be run.

Another option I considered was removing the primary Windows drive and placing the Linux drive in the system as the primary drive. I could then install GRUB on the Linux drive (the primary now) and configure it to also boot Windows on the secondary drive. One caveat here is you must configure GRUB to fool the Windows drive into thinking it is still the primary. Otherwise, Windows gets confused. I elected not do this type of install because it seemed more complicated than installing Linux on the second drive.

Boot sector transplant

The next step in the process is to save a copy of the Linux boot partition. This can be done either with dd in Linux or with the free Bootpart utility under Windows. Either program simply takes the first 512 bytes on the disk and puts them into a file. The dd command to do this is dd if=/dev/hdb1 of=bootsect.lnx size=512 count=1. Once you have this file, copy it to a diskette or some other removable media so you can then copy it to the Windows drive for NTLDR.

I happened to use Bootpart because I forgot to use dd before I booted the system back to Windows. If you use Bootpart you don't have to copy the boot sector to a diskette, as you are already in Windows. To complete the transplant, place the file you created with dd or Bootpart on the Windows drive as C:\bootsect.lnx.

Now it's time to tell Windows about Linux. Again, there are two ways to go about this. If you are doing everything manually, fire up a text editor in Windows and edit the file c:\boot.ini. Add the line c:\bootsect.lnx="Linux" to the end of the file.

The Bootpart way to do this is simpler: run Bootpart with the command bootpart Linux c:\bootsect.lnx "Linux". Bootpart will take care of adding the proper entry to boot.ini for you.

Testing and final thoughts

Your system should now be correctly configured. To test it, reboot the machine. After the BIOS screen, the first thing you will see is the NTLDR menu asking which OS you wish to boot. If you do nothing you will go to Windows. If you choose Linux on this screen, NTLDR will use bootsect.lnx to hand off the boot process to Linux, and start booting from your second hard drive. The next screen you will see will be your Linux bootloader screen. From this point on, your system boots the same as any other Linux machine.

And there you have it: a Windows machine that boots Linux as well. The advantages of this setup are:

  • The Windows configuration remains essentially untouched.
  • No changes to the Windows hard drive boot sector are necessary.
  • Removing Linux from the machine is simple: physically remove the Linux disk and remove the Linux entry from boot.ini under Windows.
  • Windows users have a tendency to reinstall the OS from time to time. If that occurs on this system, the Linux disk would be untouched (although you might not be able to boot to it until you copy the boot sector again and fix boot.ini).

While this configuration isn't ideal for everyone, it is a great way to add Linux to an Windows machine with minimal disruption of an existing Windows installation.

Share    Print    Comments   

Comments

on Convert a Windows system to dual-boot Linux on a second drive

Note: Comments are owned by the poster. We are not responsible for their content.

You dont need a second HDD

Posted by: Anonymous Coward on February 22, 2005 01:29 AM
i have done dual boots b4 and all u have to do is make a partition and u can have both OS's on the same HDD so actually it is really easy as long as u have a big enough HDD it shouldnt b to much of a problem.

#

Re:You dont need a second HDD

Posted by: Anonymous Coward on February 22, 2005 04:45 AM
Yes, if you read the second paragraph, you would see he already knows this. The purpose of the article was to show how you could install Linux with only the most minor modifications to the Windows partition.



The article was informative. I haven't ever really messed around with the Windows bootloader.

#

Re:You dont need a second HDD

Posted by: Anonymous Coward on February 22, 2005 08:09 AM
You would have done well to research this task before undertaking it in the least competent way. You made the right choice with the second drive but then proceeded to go about the installation with a "bleeding edge" distribution instead of a more suitable distribution such as Suse, Mandrake or Debian Sarge. Grub shoud have been chosen as the boot loader. This article will mislead many users in performing a similar effort by introducing a level of unnecessary complexity. The only good thing was your link to the table of ntfs resizers. Maybe you should learn how to use Google first where you would find links to explicit instructions on how to install Linux on a Windows machine without problems with either.

#

Re:You dont need a second HDD

Posted by: Anonymous Coward on February 22, 2005 09:05 PM
Suse? Hah? I tried installing Suse 9.1 Pro as dual boot on an XP box and lost all data period. This is well documented at many sites and does not seem to be listed as a "feature" of their product. Caveat Emptor. This really ^%$^#%$# me off as I though when Novell bought Suse they would have done some reasonable testing before releasing such unstable software onto consumers in a nascent market that cannot afford such mistakes. Maybe Bill Gates can but not Linux. Funny this is had installed Linux 9.0 on another XP box no problems. Go figure. They went ahead a fixed it when it wasn't broken.....;(

#

Re:You dont need a second HDD

Posted by: Anonymous Coward on February 23, 2005 12:34 AM
You didn't lose anything. Installers corrupted only the redundant disk geometry information in the partition table thus some Windows weren't able to boot until the partition table got corrected or you set LBA in the BIOS. This wasn't a SUSE only problem but Mandrake, Fedora, Debian and anybody who had taken kernel 2.6 in use had this partition table corruption problem originally independently of the used filesystems. Partition table corruption could happen even if you prepartitioned the disk or used a 2nd one!


Unlike other vendors, SUSE actually published the problem, fixed it very quickly (it was included in SUSE 9.2) and also made it publicly available: <A HREF="http://portal.suse.com/sdb/en/2004/05/fhassel_windows_not_booting91.html" title="suse.com">http://portal.suse.com/sdb/en/2004/05/fhassel_win<nobr>d<wbr></nobr> ows_not_booting91.html</a suse.com>

#

Another method

Posted by: Anonymous Coward on February 22, 2005 12:04 PM
I once saw on The Screensavers (before the G4 crap), they put a switch in that switched the primary hardrive. Basically the switch canged the setting from cable select to primary and secondary for booting. I thought this would be a good way to do this but never have had an excuse to try it.

#

A small enhancement

Posted by: Anonymous Coward on February 22, 2005 11:43 PM
Might I suggest, as a way to ease the need to re-establish the NTLDR pointer to the Linux drive/partition that you include a small Windows filesystem/partition on the Linux drive with either instructions or a script to re-establish the link. When you re-install Windows, the partition on the second drive will have all the info needed.

Just a thought,

Ken

#

An alternative..

Posted by: Anonymous Coward on February 23, 2005 12:20 AM
Or you can do what I did.

Just leave Linux in first hard disk (hda1) and windows in the second hard disk (hdb1) and use lilo as your default boot loader.

Since MS Windows cannot boot from a second hard disk you just have to edit lilo.conf and add this lines to boot windows:

---
other=/dev/hdb1

      label="M$ Windows"

      map-drive = 0x80

      to = 0x81

      map-drive = 0x81

      to = 0x80

      table =<nobr> <wbr></nobr>/dev/hdb
---

sbp

#

Another alternative... (grub)

Posted by: Anonymous Coward on February 25, 2005 07:37 PM
I too have left Linux on hda and Windows on hdb, but use grub as bootloader.

These are the Windows-specific lines in my grub.conf:
<TT>title Windows
  map (hd0) (hd1)      # Tell the first hard drive to pretend to be the second
  map (hd1) (hd0)      # Tell the second hard drive to pretend to be the first
  root (hd1,0)         # Tell GRUB Windows is on<nobr> <wbr></nobr>/dev/hdb1 (No pretending here)
  rootnoverify (hd1,0) # GRUB won't attempt to mount the Windows drive
  makeactive           # Sets the partition to active
  chainloader +1       # Tells GRUB to load the Windows bootloader when done</TT>
(Credits to <A HREF="http://forums.gentoo.org/viewtopic.php?t=18319" title="gentoo.org">http://forums.gentoo.org/viewtopic.php?t=18319</a gentoo.org> for this one.)

#

Easiest way yet

Posted by: Anonymous Coward on February 26, 2005 12:22 AM
Dual boot on a single drive system seems to be no problem.

A multi drive system has been a headache no matter which distro I have installed. And not work half the time. I had to resort to the bios boot table the AMI bios has on the one machine.

Using bootpart made this install the easiest yet. I did copy the boot.ini to CD for future installs. I have a scheduled job that creates a copy of important config/option files like this. Found it was necessary as Win98 needed to be reinstalled every 18 mos or when the spyware overruns the winxp system.

Thanks for the info

#

Dual boot single disc on a cheap machine

Posted by: Anonymous Coward on March 22, 2005 09:05 AM
I setup dual boot WindowsXP Linux on a cheap machine over the weekend. I doesn't really has any challenge if you want to keep it simple:

Choose the custom partition option, Resize the Windows_C drive with Mandrake to create space for Linux, install Mandrake packages and it and install the Linux boot loader on the MBR. I have read in many places that te Linux Boot loader should be on the first sector of the boot partition, tried it, and Linux did not show (one could boot in rescue mode and fix it, but why take the extra steps?).

There are more details on my machine and the constraints that I had on my blog page at <a href="http://www.netforall.com/servlets/ShowSite?reqtyp" title="netforall.com">http://www.netforall.com/servlets/ShowSite?reqtyp</a netforall.com><nobr>e<wbr></nobr> =showblog&admin=Poly

#

Re:Dual boot single disc on a cheap machine

Posted by: Administrator on March 22, 2005 09:10 AM
My blog page link was cut. Just go to:
<a href="http://www.polystreet.com/" title="polystreet.com">http://www.polystreet.com/</a polystreet.com> and click on blog

#

tnku!!

Posted by: Anonymous Coward on March 16, 2006 07:03 PM
tnku very much!!!
i was tired of reading and reading tips for dealing with the dual boot, but finally your recomendation of use the bootpart results in the most easy and efficient way to use linux and xp in the same machine!!

tnxs!

#

Really easy way to dual boot

Posted by: Anonymous Coward on January 24, 2007 07:40 AM
Unplug your windows drive, and plug in the drive, you want to put linux on. After you have linux working fine. Plug the drive with windows back where it was, and go to the BIOS and set the windows drive as the master and the linux drive as a slave(you will also have to properly configure the jumpers on the drive.) Then whenever you want to boot linux, just go to the BIOS and select which drive you want to boot from!!! Or if you dont know muck about these things, you can just set both jumpers as "master" and manully unplug and plug in the drive you want.

#

Re:Really easy way to dual boot

Posted by: Anonymous Coward on March 30, 2007 11:34 PM
That is an easy way, but I think your method is more suited for the at-home user.

The author of this article was providing a solution for an enterprise environment. In this situation, giving the user unrestricted access to the BIOS is not a good idea.

#

dual boot fedora 3/winxp with grub

Posted by: Administrator on February 28, 2005 01:07 PM
I have to say that PJ Hollenback gave me the final bit of info that allowed me to dual boot winxp fully updated on hda1 with fedora core 3 fully updated with no<nobr> <wbr></nobr>/boot, everything on / and<nobr> <wbr></nobr>/usr, on hda5. I had been following the discourse on dual booting @ Ed's software guide on Linux and all I got was an empty file when I followed the "dd" command. The whole thing can be found at http://www/geocities.com/epark/linux/grub-w2k-HOW<nobr>T<wbr></nobr> O.html
A very big thanks to the gentlemen who contributed.
I modified PJ's dd command the the following to suit my installation and I now have ntldr booting
both winxp and fedora 3 perfectly.
"dd =if/dev/hda5 of=media/floppy/bootsect.lnx bs=512 count=1" Copy the file to c:\ then add c:\bootsect.lnx="linux" to boot.ini and away you
go.
Thank you PJH

#

Worked great - Fedora 6 and XP!

Posted by: Administrator on May 18, 2007 11:42 PM
Thanks for posting this solution. I have done multi-boot systems using grup and gag, but I needed a more discrete way to camouflage a second system on this machine. I simply left the name of the second option (Fefora 6) blank, so other users see the ntldr boot screen (for timeout=5 seconds), then XP boots. Those in the know, use the tab or down arrow to select the blank line -<nobr> <wbr></nobr>:)

#

Convert a Windows system to dual-boot Linux on a second drive

Posted by: Anonymous [ip: 91.108.192.140] on July 26, 2007 10:47 AM
use GRUB !!! or try out back track 2 !!! not permenent but very gd !!!

#

Slackware 11.0 Experience

Posted by: chicken_soüp on September 18, 2007 06:27 PM
I implemented this solution on my machine, and I really liked it because it didn't disrupt my Windows installation at all. Whenever I got stuck I could just boot into XP and check the net for solutions. The concept is great.

One important point specific to Slackware: The GRUB didn't work, but LILO worked like a charm. I tried GRUB but I kept getting a black screen of death with the single word "GRUB" and a flashing cursor. I deleted /boot/grub, ran liloconfig, installed LILO onto my Slack partition, updated the bootsect.lnx on Windows, and bam! Slack booted no problem. The only change was from the GRUB to the LILO, so the grub was getting hung up somewhere.

Despite the fact that it works, I feel a little guilty and defeated because I couldn't get the GRUB working. It has a pretty good reputation, and I'm not one to give up on stuff, but the GRUB seems to be in an "in-between" phase right now. GRUB 1 (v0.97) is not supported, as GRUB 2 (v1.95) is in development. GRUB 2 has with little documentation. When the GRUB 2.0 is released I might try it again. I just ordered Slack v12 so I'm going to have to reinstall anyway so I might try the GRUB 1.95 a try just for $h1ts and giggles. Hope this helps someone out there! Sincerely, Teh Soüp....UT3: HERE I COME!

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya