How to keep Windows unchanged and able to boot Linux, BSD or Solaris

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

saikee

Thread Starter
Joined
Jun 11, 2004
Messages
3,888
This thread describe how a Windows user can keep his/her Windows system untouched but still able to boot Linux, BSD and Solaris. Since a simple but powerful boot loader, unattached to an operating system, is use the Windows user can have more than 100 systems installed and able to boot any of them with this arrangement.

One line summary – Put Grub in a data-only Fat primary partition and switch on its booting flag. Windows MBR can then boot up Grub which can then boot any of Linix, BSD and Soloaris installed in the PC

(A) Introduction

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 in binary pattern only. It has no filing structure so it can be put into any filing system. Windows MBR boots a Fat partition which Grub also supports.

(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 target 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.

(D) Some known features

(1) For the purpose of hosting Grub the primary Fat partition can be very small. Only 3 files are needed from Grub; stage1 is 512 bytes, stage2 is less than 150 k bytes and menu.lst is a text file with only a few lines. A user edit menu.lst to control Grub. Generally between 2 to 3 lines of commands are needed for boot a system up. Grub uses 3 lines of identical commands to boot every Dos, Windows, Linux, BSD, Solaris and Darwin x86, changing only the partition reference.

(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, if the partition is prepared by a Linux..

(3) The text file 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. Every PC system can be booted up in a Grub prompt.

(4) NT versions of Windows of XP and Win2k can multi boot Linux, BSD and Solaris. Its boot loader NTldr is more difficult to set up and maintained as boot.ini is hidden file and every non-MS system must have its boot loader copied and made available in Windows “C” drive. Using Grub in this method is simpler and able to boot many more systems than NTldr, which has a static booting screen for accepting only 10 booting entries.

(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.

A Windows user can then have access to as many Linux, BSD and Solaris systems as he/she wants and use the non-MS systems to complement Windows. Some of the known benefits are

(a) Linux and BSD can be a giant utility to Windows
(b) Non-MS systems generally have a better and more in-depth partition and disk utilities tools as they have to cope with more partition types. As such they are ideal for accessing and retrieving data from a unbootable Windows disk.
(c) Linux can be used to mirror a bootable Windows partition or disk.
(d) Linux boot loader can boot all the MS systems install into the PC whereas NTldr is limited to one Dos-based system.

The method has been written to suit for PC users without access to a floppy drive.

(F) Implementation

The method described below is for a user with a single hard disk and no access to a floppy disk. The availability of either device can make the implementation considerably easier and has been explained in this thread

(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 last can be omitted if there is an existing data-only primary partition available. Both Linux and Swap can be in logical partitions. If the Linux comes in more than one CD or in a DVD then it may need 10Gb on its own. Swap is usually chosen as twice the size of the physical memory. Solaris may need 15Gb. Partition for a BSD is similar to a Linux. Solaris and BSD systems needed to be installed in primary partitions.

(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 can be different to the one finally installed. The “Qtparted” can be used for resizing the hard disk and creating the necessary partitions. It works just like Partition Magic. For the purpose of description I assume the disk is IDE type and so Windows is in the first partition known as hda1 in Linux, which calls the hard disks hda, hdb, hdc and hdd according to the position in the two IDE ribbon cable. Disk hda is the normal first bootable disk and hda1 will be the “C” drive. Partition hda2 the data-only Fat partition, hda3 the Linux partition with partition ID 83 and hda4 the swap with partition ID 82. 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 (partition ID bf) and various BSD partition types (a5, b5 and a9 etc). I suggest using Linux partitioning tools because Windows does not support non-MS partition and so not possible to partition them inside Windows.

(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
Code:
mkdosfs –F16 /dev/hda2
and takes split seconds.

Install Grub into the data partition hda2. This is done by booting up with the Kantotix, which uses Grub as the boot loader, choose terminal mode, made a /mnt/hda2 directory, mount “device” hda2 on it and ask Kanotix to tell us where has it stored Grub’s stage1 (stage2 is always stored together with stage1).
Code:
mkdir /mnr/hda2
mount /dev/hda2 /mn/hda2
find / -name stage1
Everything in Linux is a file and the data-only is accessed in Linux by typically mounting as above. The operation is necessary because two operating systems are involved.

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.
Code:
mkdir /mnt/hda2/boot
mkdir /mnt/hda2/boot/grub
cp /KNOPPIX/lib/grub/x86_64-pc/stage1 /mnt/hda2/boot/grub
cp /KNOPPIX/lib/grub/x86_64-pc/stage2 /mnt/hda2/boot/grub
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. MS systems use “\” in the directories but non-MS systems are standardised on “/”.

Now is the time to invoke a Grub shell inside Kanotix and install Grub into the data-only partition.
Code:
grub
Grub can be formally set up inside hda2 by these commands in Grub shell
Code:
root (hd0,1)
setup (hd0,1)
makeactive
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 multi booting with Grub. Reboot the system now 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
Code:
root (hd0,0)
makeactive
chainloader +1
boot
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
Code:
root (hd0,0)
makeactive
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”.

During any time if Windows fails to boot it is only because its partition has not been made active. A Windows partition can be made active by running a Freedos CD, using the fdisk.exe program.

(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

Code:
#My 1st attempt writing a booting menu
title Windows in hda1
root (hd0,0)
makeactive
chainloader +1

title Linux in hda3
root (hd0,2)
chainloader +1
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. However you can use it to boot the “high-lighted” Windows by just pressing the return key.

(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 their boot sectors 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” whenever 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
Code:
fixmbr
exit
The Freedos offers a CD ios image which you can burn and boot up to a Dos prompt. You can then type
Code:
fdisk /mbr
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.

(10) The above method requires the user to make the data-only partition active if he/she wants to use a non-MS system in the next reboot. This operation is unnecessary if he/she has a floppy drive or another hard disk. The non-MS partitions can be erased by Windows at any time.

The Windows system and it MBR are untouched at all time.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top