# IG2: How to install Gentoo in a Win XP/NT config

## plate

Navigation: [Installing Gentoo] [Table of Contents]

How to install Gentoo in a Win XP/NT configuration

This is just a synthesis of tips and tricks I found on various websites to make this work. It may come in handy when you want to add Gentoo on a PC with only one harddisk that has XP preinstalled on a single NTFS partition. Everything here is based on Gentoo's basic installation guide which I followed religiously except for the partition numbering. Here is what I did:

* Downsize an existing partition to make space for Gentoo

* Create logical partitions (hda5 and up) for Gentoo

* Install Gentoo without touching the Master Boot Record

* Use NT loader to choose between XP and Linux, boot Gentoo from GrubI am sure there are more elegant ways to do this, notably without the use of ye olde NT loader, but I know there are people out there who need to keep an existing Windows installation for whatever reason (mine was Adobe InDesign...) and don't want to reinstall everything. These tips should also work for Windows 2000, by the way.

IMPORTANT NOTE: Don't bother following these instructions if you're using a separate disk for your Linux installation. Darth_Daver's howto explains in detail how to leave the Windows disk and its NT loader untouched, and still be able to use GRUB for booting both operating systems.

Before you start, backup your system.

Until Linux support for NTFS emerges from the experimental stage that is reportedly going to kill your disk before you can say "wobble", you will need to resize the disk before you boot the Gentoo installation CD. I used Partition Magic 7.0 for that, mainly because I couldn't find anything else that could do this for NTFS partitions:

1. Resize the C: drive

PM makes this very easy, just click on the resize button and let the wizard take over. All you need to decide upon is the size of the XP partition you want to keep, everything else is automatic. You need to reboot, and the PM script then neatly reslices your disk.

2. Add a Linux partition

I tried to do this with fdisk first, but eventually had to boot back into XP and use PM because fdisk still said that /dev/hda1 was spanning the entire disk, and I didn't dare to make any changes. It is entirely possible that this is no big deal for an expert, but for me it certainly was... Anyway, in PM, I installed a Linux partition using the wizard again. PM asks you if you want to install an OS on the new partition, you have to say no to this because otherwise it will attempt to create your partition before drive C. This leaves you no choice but to make the new partition a logical drive rather than a primary one, but that's just fine.

3. Use fdisk to repartition for Gentoo

Boot the installation CD and do everything by the book. When you run fdisk, the partition table looks something like this (on my 40 GB drive it did):

```
Disk /dev/hda : 255 heads, 63 sectors, 4865 cylinders

Units = cylinders of 16865 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      2550  20482843+   7  HPFS/NTFS

/dev/hda2          2551      4865  18595237+   f  Win95 Ext'd (LBA)

/dev/hda5          2551      4865  18595237+  83  Linux

```

Next, just delete the /dev/hda5 entry and create three new partitions, except that you number your partitions hdaN+4 for each of the partitions in the installation guide. This is what it should look like after you're done:

```
Disk /dev/hda : 255 heads, 63 sectors, 4865 cylinders

Units = cylinders of 16865 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda1   *         1      2550  20482843+   7  HPFS/NTFS

/dev/hda2          2551      4865  18595237+   f  Win95 Ext'd (LBA)

/dev/hda5          2551      2563    104391   83  Linux

/dev/hda6          2564      2691   1028128+  82  Linux swap

/dev/hda7          2692      4865  17462623+  83  Linux

```

I know my swap partition is probably too large, but as I said: I'm following the installation guide word by word, and it recommends to allocate two times RAM here. The next step is to choose a filesystem for each of your partitions and continue with the installation, we'll skip all that because you can do it exactly like the guide says, always keeping in mind your different partition numbers, especially when it comes to editing /etc/fstab, n'est-ce pas. 

4. Configuring Grub

Completely unnecessary to do anything tricky here, just bear in mind that your partition numbers have to correspond:

```
grub> root (hd0,4)

grub> setup (hd0,4)

grub> quit
```

does it. Make sure you setup the Grub boot record on (hda0,N), not simply (hda0). (hda0) would point to your MBR that doesn't have a clue about your Linux installation (and never will).

5. Prepare a bootable file for the NT loader

The NT loader is run by a script called boot.ini  that's hidden in the root directory of your C: drive. To boot Linux, this script would have to call a dummy boot sector file that you need to create and copy to your C: drive. If XP was using a FAT32 file system, you could simply mount the drive and create the file at the right location (this may work in W2K if you happen to have it installed on a FAT drive), but since it's NTFS we're talking about you'll have to create the file and then see how you get it into place next time you boot XP.  Do this:

```
dd if=/dev/hda5 of=/tmp/yourfilename.bin bs=512 count=1
```

I then ftp'ed the file yourfilename.bin to another PC and retrieved it from there, but you could also mcopy it to a floppy, I suppose. That's it, you're ready to unmount everything and reboot your PC.

6. Copy yourfilename.bin to C:\

If you haven't forgotten to take the CD out of the tray, you will boot back into XP. Move your fresh dummy boot sector file to the Windows root directory C:\. You can probably set attributes to create this as a hidden file, but I have no idea how one does that.

One important note (added several months after writing the original text): Repeat steps 5. and 6. every time you upgrade your GRUB! It took me quite a while to understand why my boot splash window continued saying it was version 0.90 in spite of several updates I had done since then, and worse things are known to happen...

7. Edit boot.ini

You need to tell the NT loader about the new OS you've just installed, so you will:

* Go to Control Panel, start the Performance and Maintenance tool, and then click System.

* On the Advanced tab, click Settings under Startup and Recovery.

* Under System Startup, click Edit.This it what it'll look like:

```
[boot loader]

timeout=30

default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS

[operating systems]

multi(0)disk(1)rdisk(0)partition(1)\WINDOWS="Windows XP Professional" /fastdetect
```

All you have to do is add one line at the end of this file:

```
C:\yourfilename.bin="Gentoo Linux"
```

and you're done, just save and exit, reboot, voila, the NT loader pops up and gives you a choice now. You could also change the default to Linux if you want, of course. Select "Gentoo Linux", and it'll load Grub and fire up your pretty Gentoo installation.   :Very Happy: 

Navigation: [prev IG1: Installation from a boot floppy HOWTO ][Installing Gentoo] [Table of Contents]Last edited by plate on Tue Jun 10, 2003 10:04 am; edited 2 times in total

----------

## pilla

Feedback to this thread.

----------

