Dual booting Linux and Windows 2000/XP on large hard disks

Bruce P. Blackshaw

Introduction

This is how I installed W2K and Linux to dual boot on a single large IDE disk, 30 GB in size. I used the W2K boot manager to control the dual boot. It worked for me, so hopefully it will work for you. Any contributions or corrections welcome - please post on our discussion forum. XP and W2K share the same boot manager so this will work for Windows XP. Unforunately we can't answer individual emails.

Thanks to Marko Koivuporras for a Finnish translation of this article. Any errors in translation are his :-)

General

Windows 2000 has the same boot manager as NT 4.0, so the procedure should be identical for dual booting NT4 and Linux.

Step by Step

1. Plan your hard disk layout carefully

I allocated space for a W2K partition, Linux and a shared partition in that order.

Important: With some exceptions (see below), the Linux boot partition must be in the first 1024 cylinders of the disk(approx the first 8 GB). This implies that the W2K partition cannot be any larger than about 7.5 GB, to allow /boot to be the next partition still within the 1024 cylinders. Linux will not boot correctly if /boot is past 1024 cylinders (but see below). 

I set up a 6 GB FAT32 partition for W2K, followed by 18 GB for Linux (unformatted) and the remaining 6 GB for data shared between Linux and W2K.

You can use fdisk from a boot floppy (Linux, DOS or Windows) to do the partitioning at this stage, or just do it when you install W2K.

My final layout looked like this:

================================== Cylinder 0

W2K (6 GB) - FAT32 (NTFS does not seem to work!)

==================================

Linux (18 GB) - unformatted

==================================

Shared (6 GB) - FAT32

==================================

2. Install W2K on your first partition

If you haven't set up the partitions as described in (1), you can create them as you are installing W2K.

The W2K install should be straightforward. It gives you the option of partitioning and formatting the disk. I made the first partition for W2K FAT32. 

Warning: I have received several reports that NTFS will not load the Linux boot sector. Stick to FAT16 or FAT32. If you really want NTFS, create a small FAT32 partition of perhaps 800 MB for W2K/NT and another 5GB NTFS, instead of the 6 GB suggested above.

Once the install is completed, W2K should boot correctly, and in the Computer Resource manager you should be able to see the unused partitions. You can also format the shared partition as FAT32 at this point, or do it later

3. Install Linux on your Linux partition

Do this as per your Linux installation. Ensure that you don't overwrite the first partition containing W2K. 

Important: Do not install LILO on the disk's MBR. This will stop W2K from booting. Instead, make sure it is installed on the /boot partition (which should be the second partition on the disk).

Important: As discussed earlier, the Linux boot partition must be the first partition after W2K partition, to ensure it is within the 1024 cylinders limit. If you don't do this, Linux will not boot correctly - unless you are using a very recent version of LILO with lba32 support and a recent lba32 BIOS. For more details, see below.

Important:  Don't reboot until you have performed steps 4.1 and 4.2. If you reboot, you'll have no way to get back into Linux again unless you created a Linux boot disk (a good idea).

4. Set up the dual boot

You have two options for setting up the dual boot - either following my instructions below, or using the bootpart tool. I have not used bootpart myself, but a friend has used it successfully on his machine. It seems like a good tool, and does the equivalent of steps 1-4, below.

  1. From Linux, copy the Linux boot sector from /boot to a file using the dd command.

  2. In the below, replace /dev/hda3 with your boot partition's location
    # dd if=/dev/hda3 of=/bootsect.lnx bs=512 count=1
     

  3. Copy bootsect.lnx onto a floppy disk.

  4. If mcopy is available, this is easy:

    # mcopy /bootsect.lnx a:
    

    If mcopy is not available (e.g. a minimal install of Linux) you'll need to mount the floppy drive and then copy:

    # mount /dev/fd0 /mnt
    # cp /bootsect.lnx /mnt
    # umount /mnt
    
  5. Boot W2K, log in as Administrator and copy bootsect.lnx from your floppy disk onto the root of your C: drive

  6. Edit C:\BOOT.INI and add the following line at the end:

    C:\BOOTSECT.LNX="Linux"
    

5. Test

Reboot and see if you get the following menu:

Windows 2000 Professional
Linux

If you don't, you've made a mistake editing BOOT.INI.

Test booting each operating system.

If when booting with LILO the machine hangs, displaying part of the word "LILO", it is possible that

6. Mount the shared partition

If you haven't formatted the final shared partition as FAT32, do so now from within W2K. Be careful not to format any of the Linux partitions. For convenience, I labelled it as D: drive, C: being my primary W2K partition.

Copy a test text file into D: while in W2K.

Then reboot into Linux, create a mount point (say, /w2k) and mount the shared partition to test it. Change hda6 to whatever your partition is called.  (Running fdisk as root in Linux will list your partitions, using the "p" option)

# mount /dev/hda6 /w2k
If you can successfully mount the shared partition and can read the test text file, you're almost done.

Note:  if you mount a fat partition from within Linux, by default the partition (and all files and directories within it) will be owned by the process which did the mounting. So if it is listed as being mounted at boot time in /etc/fstab it will be owned by root. Flags are available to change these defaults.

I mount my shared partition so that it is owned by me, by adding the flags that give me ownership. I also set the gid to users and the umask here.

Here's my /etc/fstab entry:

/dev/hda6    /w2k    vfat    uid=500,gid=100,umask=002 0 0
Reboot and test /w2k has been mounted correctly. Then you're done.

Note on 1024 Cylinder limit

The 1024 cylinder limit has been broken! Support for the lba32 BIOS extension has been added to LILO by John Coffman. For motherboards made after 1998 (or with upgraded BIOSes), LILO will detect the BIOS extension and you are able to install the boot partition where ever you like. You need:

For more detailed information on lba32, see the Large Disk HOWTO - Booting.

Useful tools

If you are already running W2K, your disk needs repartitioning to install Linux, and you do not wish to destroy your current W2K installation, consider using a disk partitioning tool.

Warning: before using any of the following tools, back up your critical data!

The alternatives I know about are:

References

  1. NT OS Loader + Linux mini-HOWTO.
  2. Large Disk HOWTO