To install Linux and keep Windows untouched like a virgin
--------------Re-written 5/1/06 to include detailed Grub & Lilo commands, Section C added -----------
--------------Section C re-written on 12/1/06, dropping Grub4dos using only Grub itself------------------
--------------18/1/06 "Just Booting Tips" reference added---------------
--------------18/8/07 There is a 4th method now by a virtual machine management layer. I shall add details when I got time ---------------------
--------------30/10/07 New Section D and Section E added ---------------------
Three methods are described in Post #1 and two in Post #39
Section A : Two hard disks available
Section B : Single hard disk with a floppy drive
Section C : Single hard disk no floppy drive
Section D : Single hard disk. Linux booted manually by a selected Linux Live CD(newly added 30/10/07 in Post #39)
Section E : Linux installed and booted from an external USB device (hard disk /pen drive)(newly added 30/10/07 in Post #39)
There is a collection of booting tips now available in HERE
Section A : Two hard disks available
One line summary - Windows installed in Master drive, use BIOS to boot Slave ahead of Master, install Linux in the slave and use the slave's MBR to multi boot- to go back just reverse the boot sequence
Assuming the Windows is in the Master drive and boots up as normal to start with.
Use Bios to select the slave to boot ahead of the master drive so that Linux can be installed into the slave
Create a partition for the Linux and also a swap partition.
Instruct the installer to intall the Linux in pre-arranged partitions. Ask the bootloader to be install into the MBR which now goes only to the Slave disk. Linux can be installed and booted from either a primary or logical partition.
On reboot the Linux will be booted by its boot loader in the Slave's MBR. The Windows may need the disk order "re-mapped" before it can be booted.
If the Linux uses Grub make sure the following lines are in /boot/grub/menu.lst
If the Linux uses Lilo make sure it has the following lines in /etc/lilo.conf
title Windows installed Master (hd0) now booted from (hd1)
map (hd1) (hd0)
map (hd0) (hd1)
The red statements "re-map" the 1st and 2nd disks "on-the-fly". Grub counts from 0 so (hd0) is the 1st bootable disk.
map-drive = 0x81
to = 0x80
map-drive = 0x80
to = 0x81
Anytime you don't want to see a trace of Linux just reverse the boot sequence in the BIOS.
Your Windows MBR in the master disk is untouched like a virgin.
Section B : Single hard disk with a floppy drive
One line summary - Use a fllopy or a CD to boot Linux. Windows automatically booted without the floppy or CD
Try to squeeze two partitions out of the hard drive. One for Linux in the second primary partition after Windows and one for swap which can be in a primary or logical partition. The write-up assumes Linux is in the second primary partition of the disk and so adjustment to the partition reference is needed if your case differs.
Assuming Windows installed first and working normally in the first primary partition.
Boot up the CD and install the Linux in the created second primary partition.
Must not allow Linux to place bootloader in MBR, instruct the installer to install its boot loader inside its root partition.
After the Linux installation completed and rebooted there should be no trace of Linux.
Having satisfied that only Windows is available without Linux go to distowatch to download a Live CD from either Mepis, Puppy, Ubuntu or Damn Small Linux and burn it into a CD.
Boot up this Live CD and ask Linux to report to you the directory it stores Grub's stage1 and stage2 files by this command
You then change directory to it and create a Grub bootable floppy unattached to an operating system by using Linux's dd command. I am using the directory location from Mepis Live CD but do adjust the directory name if you source the stage1 and stage2 from another Linux.
find / -name stage1
This Grub floppy can boot any PC system manually. I have not been able to find a PC operating system that cannot be booted by it. For laptop user you can generate the Grub floppy using a friends PC and burn the floppy into a CD using the method described at this site.
dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1
The Grub floppy (or CD) boot up a Grub prompt only but your Windows can be booted by the following instruction
and your Linux too with the same instructions except you advance the partition reference by 1 as follow (Grub counts from 0 so (hd0,1) is the 2nd partition of the 1st disk)
There may come a time you no longer wish to type the instruction manually. In such a case you put the Linux's own boot loader in a floppy when you are using the Linux.
Pop a floppy into the drive. If it uses Lilo your type
If the Linux uses only Grub the equivalent command is
The second floppy can boot up the Linux without any typing.
So without the use of a floppy or CD Windows will boot. Put in the floppy or CD Linux boots up instead.
Your Windows MBR is untouched like a virgin.
Section C : Single hard disk and no fllopy drive
This is a technique of using Windows MBR to boot Linux ( or BSD or Solaris)
One line summary – Put Grub in a data-only Fat primary partition and switch on its booting flag. Windows MBR will faithfully load Grub into memory. Grub can then boot all systems installed in the PC
Windows MBR does not have a target to boot. It only searches from the 4 primary partitions of the bootable hard disk and loads the first one that has the booting flag switched on. One can make use of this behaviour to let it boot up GNU/Grub, a boot loader developed for Linux but can be installed without an operating system. If we put Grub into an “active” data-only Fat primary partition then Grub becomes available to multi boot other systems.
The write-up below is mainly for Linux as Grub is sourced from it. By expanding its booting menu Grub can be used boot 100+ systems. The booting of BSD and Solaris is not fully described here because the method is identical to the case of Grub booting a Windows. See above link for more explanations.
(B) Theoretical explanations of why the scheme works
(1) As a boot loader Grub is in binary pattern. It has no filing structure so it can be put into any filing system. Windows MBR boots a Fat partition which Linux can read and write.
(2) A data-only primary partition has no operating system inside and its reserved boot sector is unused and empty. Putting Grub there does no harm and creates no inconvenience.
(3) All Windows versions have a facility for marking another partition “active” and so it is possible to switch the booting alternative to a data-only primary partition. The data partition boots if Grub is installed inside.
(4) Grub is a rare boot loader that can be installed without an operating system.
(C) Necessary conditions
(1) The partition hosting Grub must be a primary type.
(2) The partition hosting Grub must be in Fat12, Fat16 or a Fat32 format. Linux does not yet write on NTFS partitions. Put Grub in a non-MS partition will not attract Windows MBR attention.
(D) Some known features
(1) For the purpose of hosting Grub the primary Fat partition can be very small. Only 3 files are needed; stage1 is 512 bytes, stage2 is less than 150 k bytes and menu.lst is a text file with only a few lines.
(2) For the hosting Grub only the fat partition is not subjected to the usual DOS restrictions, as no Dos system is used. Thus the Fat data-only partition can be created in a Sata disk and at the end of a 300Gb disk.
(3) The menu.lst in the data-only partition if omitted will force Grub to boot to a Grub prompt whereby the user has to boot up each system manually. The optional menu.lst is just a script file to execute the same commands automatically.
(E) Application area
The method outlined here enables a Windows user to install and boot up Linux , BSD and Solaris systems with absolutely no alteration to the Windows system and its MBR.
The method has been written to suit for PC users without access to a floppy drive.
(1) Resize the hard disk to make available unallocated space for about 6Gb. For first-timer a 5Gb partition for Linux, 0.5 Gb for Swap partition and 0.5 Gb for a data-only primary Fat partition. The latter can be omitted if there is an existing data-only primary partition available. Both Linux and Swap can be in logical partitions. Linux comes in more than one CD or in a DVD may need 10Gb on its own. Solaris may need 15Gb. Partition for a BSD is similar to a Linux. Solaris and BSD systems needed to be installed in primary partitions. The only exception I am aware of is NetBSD which can be accommodated in a logical partition.
(2) Download a Linux Live CD iso image and burn it into a CD. Ideal one should have “Grub” and “Qtparted” inside, like Kanotix or Knoppix. The Live CD can be used just as a tool and different to the one finally installed. The “Qtparted” can be used for resizing the hard disk and creating the necessary partitions. For the purpose of description I assume the disk is IDE type and so hda1 is the Windows, hda2 the data-only Fat partition, hda3 the Linux partition and hda4 the swap. Had the Linux and Swap been formed as logical partition it would be named automatically as hda5 and hda6, as the first 4 are reserved for primaries only. If the disk is a Sata type then all “hda” will have to change to “sda”. It is a good practice to reboot the system after partitions have been created. The other partitioning tools in Linux are the “fdisk” and “cfdisk” in command mode and they are more versatile in supporting Solaris and various BSD partition types.
(3) There is no need to format the two Linux partition as every Linux installer will want to do itself. Only the data-partition if created new will need to be formatted. This can either be done in Windows or in Linux Live CD. To format a Fat16 partition of hda2 in Linux terminal command is
(4) Install Grub into the data partition hda2. This is done by booting up with the Kantotix, which uses Grub as the boot loader, made a /mnt/hda2 directory, mount it and ask Kanotix to tell us where has it stored Grub’s stage1 (stage2 is always stored together with stage1).
mkdosfs –F16 /dev/hda2
Kanotix should report back the files found in /KNOPPIX/lib/grub/x86_64-pc, so made a /boot/grub directory in /mnt/hda2 and copied the two files across.
mount /dev/hda2 /mn/hda2
find / -name stage1
if another Live CD is used just change the directory reported by your Live CD in the above two lines. It is essential that stage1 and stage2 to be stored only in the /boot/grub directory of hda2 because that is where Grub will look for them.
cp /KNOPPIX/lib/grub/x86_64-pc/stage1 /mnt/hda2/boot/grub
cp /KNOPPIX/lib/grub/x86_64-pc/stage2 /mnt/hda2/boot/grub
Now is the time to invoke a Grub shell inside Kanotix
Grub can be formally set up inside hda2 by these commands in Grub shell
The last statement makes the PC boot hda2 instead of Windows in hda1.
(5) The system should be tested so that a user knows the basic steps to survive in booting. Reboot the system at this point will fire up Grub to a command prompt without any trace of Windows. Don’t panic as this is precisely what it should be. You can get your Windows back immediately by booting it manually with these line in Grub prompt
Since Windows partition becomes active rebooting the PC will return back to Windows and not Grub in the data-only hda2 partition. If you want to boot back to Grub in hda2 just do the following before you exit Windows
Click My Computer/Manage/Storage/Disk Management and then right click hda2 to select “to make partition active”
When you boot to Grub there is no system available except the commands in Grub prompt. You can make Windows partition active any time by the commands
To look at what commands you can use in Grub the command is “help”. To view the partitioning scheme of your hard disk you type “geometry (hd0)", to reboot just type “reboot” and to power down is “halt”.
(6) Although not straightly necessary it would be a “cool” thing to do by writing a booting menu yourself and have it ready before you even install the Linux. You can do this in Windows, use notepad only as the booting menu must be a text file called menu.lst in the \boot\grub directory of hda2 which should be your drive “D”. So just create \boot\grub\menu.lst with the following lines
This file should be in your “D” drive. If created it will be seen the next time when you boot up hda2. You can still use the Grub prompt by press “c”. Hda3 is not yet bootable because you have not yet installed a Linux inside hda3 yet.
#My 1st attempt writing a booting menu
title Windows in hda1
title Linux in hda3
(7) Now install a Linux (or Solaris or BSD) of your choice. Pay attention to the questions and instruct the installer to install the Linux into hda3. This is usually asking the installer using hda3 as the root “/” of the Linux. The installer should automatically know what to do with the swap partition. The critical issue in a Linux installation is to insist the boot loader to be installed in its root partition. Under no circumstance allow the boot loader go to the MBR. On completion of a full installation your Linux can be booted by the menu.lst you have created. Linux is born to multi boot. During installation it will check hda1 and hda2 and realise Windows MBR and Grub are inside respectively and so it could build up a menu to both these two partitions inside hda3. Thus you may end up hooping between hda2 and hda3 partitions and able to fire up Windows from either of them.
(8) The Linux you choose can have any type of boot loader. It can be a BSD, a Solaris or a Darwin x86. As long as you deny the system to install its boot loader into the MBR it has no alternative but to put the boot loader inside its root partition. That makes the system “chainloadable” by Grub. A Linux partition does not need to be active in order to be booted up. Neither does a BSD or a Solaris if it is booted by Grub. Windows is the only exception that needs its boot flag “switched on” when being booted.
(9) There is no harm done if you do make a mistake overwriting Windows MBR with a Linux (or another system’s) boot loader because you can always restore the Windows MBR either by a Windows installation CD (any one from Win2k or XP) or a Freedos CD downloadable from the Internet.
With the former you boot up the installation CD and wait until you can press R to opt for the Recovery Console where you just type
The Freedos offers a CD ios image which you can burn and boot up to a Dos prompt. You can then type
Either method will get your Windows MBR back. If the user has an access to a bootable floppy drive the Windows MBR can also be restored using the command identical to the Freedos CD.