Installing Windows® After Something Else

Modern lore often leads the naive to believe that Windows should always be installed first on any system on which it must co-exist with some other operating system, for instance, Linux. The problem with that is that inevitably Windows will need to be reinstalled. The better approach is to install such that Windows changes nothing at all, or nothing that isn't dead easy simple to undo. Then it doesn't matter what gets installed when.

How? Here's the condensed procedure for an empty single SATA HD system on which a dedicated boot manager that requires its own partition will not be used:

  1. Partition completely first, preferably with a cross-platform and/or OS-agnostic tool, to prevent booby traps from unruly installers getting in your way. Reserve for Linux /boot on SDA3, and put a small (600 MiB or less) FAT16B on SDA1 or SDA2 for Windows to boot from. Set SDA3 "active" (DOS/OS2/Windows tools) or "bootable" (Linux tools).
  2. Install Linux, but, put the bootloader on SDA3, not the MBR. Starting with a HD with no installed OS, the installer may not give you this option. If it does not, after installation is complete, install the bootloader to /boot yourself by running your choice of grub-install or lilo. Alternatively, use a distro-specific tool made for the purpose, such as YaST2 (e.g. openSUSE) or dpkg-reconfigure grub-pc (Debian and its derivatives).
  3. Add a stanza to menu.lst (Grub), grub.cfg (Grub2) or lilo.conf for the Windows SDA1 or SDA2. Do not include "makeactive", unless you want to always start boot from the NTLoader menu on the successive boot.
  4. Set the FAT partition "active"/"bootable".
    1. Install Windows.
    2. (optional) Add the Linux SDA3 boot partition to Windows XP's boot.ini, or use Windows' BCDEdit to add it to Vista and newer Windows versions' boot menu. Reboot to see if the initial boot menu is Windows'. If it is not, use a DOS or Windows utility like FDISK to install generic MBR code in place of the non-generic code set there by the Linux installer.
  5. Use any of countless DOS or Windows or open source tools to change the "active"/"bootable" partition back to Linux' SDA3 /boot (changing 2 bits in the MBR partition table).

At this point you're ready to boot either OS from the Grub, Grub2 or Lilo menu, with a fallback to booting either Windows or Linux using NTLoader or BCD if you chose option 5.B. And, you're doing it with pure generic MBR code, which simply transfers boot control to the boot record of whichever primary partition is set "active"/"bootable".

When you're done doing as above, your disk layout might be logically arranged as follows:

|ID |Dr|Type, description|hd|Format  |Related |Size MiB|
+---+--+-----------------+--+--------+--------+--------+
|01>|C:|Prim 06 FAT16    | 1|FAT16   |MSWIN4.1|    39.2|
|02 |  |Hide 11 FAT12    | 2|        |        |     7.8|
|03*|  |Prim 83 LinuxNatv| 3|EXT2    |GRUB    |   101.9|
|05 |  |Log  82 SunS/SWAP| 5|SWAP    |Linux   |   768.7|
|06 |  |Log  83 LinuxNatv| 6|EXT3    |Linux   |  4800.6|
|07 |D:|Log  0c FAT32-Ext| 7|FAT32   |MSWIN4.1|  3506.3|
|08 |E:|Log  0c FAT32-Ext| 8|FAT32   |MSWIN4.1|  4000.5|
|09 |  |Log  83 LinuxNatv| 9|EXT3    |Linux   |  6243.9|

And your Grub bootloader configuration could look similar to:

default	1
timeout		50
color		cyan/blue white/blue

title		Windows
root		(hd0,0)
# makeactive
chainloader	+1

title		Kubuntu Linux
root		(hd0,2)
kernel		/vmlinuz-2.6.15-23-386 root=/dev/hda6 ro vga=0x317 nosplash
initrd		/initrd.img-2.6.15-23-386
# savedefault
boot

title		Kubuntu (recovery mode)
root		(hd0,2)
kernel		/vmlinuz-2.6.15-23-386 root=/dev/hda6 ro single
initrd		/initrd.img-2.6.15-23-386
boot

If you performed step 5.B., your Windows' boot.ini would be something like:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(6)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(6)\WINNT="Microsoft Windows 2000" /fastdetect
C:\grubboot="Grub Boot Menu"

Assuming your Windows C: drive in Linux is mounted on /disks/C, and the disk partitioning above, you would create C:\grubboot above like so:

dd if=/dev/hda3 of=/disks/C/grubboot bs=512 count=1

Any OS installations beyond the first two are easily added to the boot.ini and/or lilo.conf or menu.lst menus. For additional versions of Windows the installer will do boot.ini automatically. Just remember during additional Linux installations to place their boot loaders on their respective /boot or / partitions, and set the Windows primary "active"/"bootable" before every Windows (re)installation.

Caution: Contrary to common folklore, all supported Windows versions are perfectly happy to use a primary partition other than the first for C:. However, if you use the first primary for something other than C:, and install Grub on the first primary, then the WinXP installation program may not continue after displaying "Setup is inspecting your hardware configuration..."


Related Links

Partitioning Tools

LicenseExecutable runs on platform
ToolGPLNon-FreeDOSLinuxMacOS/2WinNotes
CFDiskXX
DiskDrakeXXMageia
Disk DruidXXRedHat/Fedora
DFSeeXXXXXXcompiled to run on all popular platforms
FDiskXXXXXXXseveral apps go by same name (not cross-platform)
Free FDiskXX
FIPSXXresizer only
GdiskXXsupports GPT partitioning as required for disks >2TiB
GPartedXX
LVMXX
Partition LogicXno OS required
Partition MagicXXX
PartmanXXDebian
QPartedXX
QTPartedXX
Ranish Partition ManagerXX
SPFDiskXX
XFDiskXX
YaSTXXSUSE/OpenSUSE

Parent page