saikee
01-11-2006, 10:19 PM
One line summary – Put Grub in a data-only Fat partition and switch on its booting flag. Windows MBR will faithfully load Grub into memory.
This is something we should be able to do but I haven’t seen it mentioned so I tried it and reported here.
Theory
Windows MBR does not have a target to boot. It only searches from the 4 primary partitions and loads the first one that has the booting flag switched on. That is why we must make a MS partition “active” if we want it to be booted.
We can set up Grub in any partition for booting to it. The basic steps are
(1) Make a directory /boot/grub inside
(2) Copy Grub’s stage1 and stage2 files into this directory
(3) Invoke a Grub shell from a Linux
(4) Select this partition as root
(5) Run setup command.
Thus if we do this to a data-only Fat16 or a Fat32 partition the setup will implant stage1 and stage2 inside its boot sector using the source from \boot\grub directory. By make this partition active the Windows MBR will just load Grub into memory because stage1 and stage2 are binary patterns with no file type.
If we haven’t got a data-only Fat partition a small new primary partition can be created for this purpose.
Once Grub get into the memory it will take charge and boot any Linux we want.
Practice
On one machine with 28 partitions I have XP in hda1 and a Fat32 data partition in hda2. To start I restored Windows MBR by a Dos 6.22 floppy and checked XP was the only system booted.
fdisk /mbr
Booting up with Kantotix 2005-4 CD, which uses Grub as the boot loader, I made a /mnt/hda2 directory, mounted it and asked Kanotix to tell me where had it stored Grub’s stage1 (stage2 is always stored together with stage1).
mkdir /mnt/hda2
mount /dev/hda2 /mnt/hda2
find / -name stage1
Kanotix reported back the files was found in /KNOPPIX/lib/grub/x86_64-pc, so I made a /boot/grub directory in /mnt/hda2 and copied the two files across.
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
I then invoked a Grub shell inside Kanotix
grub
Grub was formally set up inside hda2 and became bootable by these commands in Grub shell
root (hd0,1)
Setup (hd0,1)
Makeactive
What a lovely sight when I booted to a Grub prompt. From it I booted to XP by
root (hd0,0)
makeactive
chainloader +1
boot
Before I left XP I clicked My Computer/Manage/Storage/Disk Management and made hda2 “active” again. If I don't do that the Windows MBR will always boot to XP because its partition is still active.
Booting back to Grub prmpt I chose Suse 9.1 in hda6 by manually booting to it with commands
root (hd0,5)
chainloader +1
boot
In Suse’s I mounted the hda2 partition and copied Suse’s menu.lst into /mnt/hda2/boot/grub, because previously I used Suse’s Grub to boot all the systems in the box.
Now I have Windows MBR permanently in the first bootable disk but it boots up XP or Grub in the hda2 Fat32 partition which has no operating system.
The only changes to the original hda2 partition are
(1) A new directory \boot\grub
(2) 3 files of stage1, stage2 and menu.lst added
(3) Boot sector is occupied by Grub
I have tried it on 3 computers and the results were dependable.
Implications
(1) More Windows users can install and try Linux because there is no need to lose the Windows MBR.
(2) Another powerful feature of Linux publicised.
(3) Making good use of the empty the boot sector available in a data-only primary partition.
This is something we should be able to do but I haven’t seen it mentioned so I tried it and reported here.
Theory
Windows MBR does not have a target to boot. It only searches from the 4 primary partitions and loads the first one that has the booting flag switched on. That is why we must make a MS partition “active” if we want it to be booted.
We can set up Grub in any partition for booting to it. The basic steps are
(1) Make a directory /boot/grub inside
(2) Copy Grub’s stage1 and stage2 files into this directory
(3) Invoke a Grub shell from a Linux
(4) Select this partition as root
(5) Run setup command.
Thus if we do this to a data-only Fat16 or a Fat32 partition the setup will implant stage1 and stage2 inside its boot sector using the source from \boot\grub directory. By make this partition active the Windows MBR will just load Grub into memory because stage1 and stage2 are binary patterns with no file type.
If we haven’t got a data-only Fat partition a small new primary partition can be created for this purpose.
Once Grub get into the memory it will take charge and boot any Linux we want.
Practice
On one machine with 28 partitions I have XP in hda1 and a Fat32 data partition in hda2. To start I restored Windows MBR by a Dos 6.22 floppy and checked XP was the only system booted.
fdisk /mbr
Booting up with Kantotix 2005-4 CD, which uses Grub as the boot loader, I made a /mnt/hda2 directory, mounted it and asked Kanotix to tell me where had it stored Grub’s stage1 (stage2 is always stored together with stage1).
mkdir /mnt/hda2
mount /dev/hda2 /mnt/hda2
find / -name stage1
Kanotix reported back the files was found in /KNOPPIX/lib/grub/x86_64-pc, so I made a /boot/grub directory in /mnt/hda2 and copied the two files across.
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
I then invoked a Grub shell inside Kanotix
grub
Grub was formally set up inside hda2 and became bootable by these commands in Grub shell
root (hd0,1)
Setup (hd0,1)
Makeactive
What a lovely sight when I booted to a Grub prompt. From it I booted to XP by
root (hd0,0)
makeactive
chainloader +1
boot
Before I left XP I clicked My Computer/Manage/Storage/Disk Management and made hda2 “active” again. If I don't do that the Windows MBR will always boot to XP because its partition is still active.
Booting back to Grub prmpt I chose Suse 9.1 in hda6 by manually booting to it with commands
root (hd0,5)
chainloader +1
boot
In Suse’s I mounted the hda2 partition and copied Suse’s menu.lst into /mnt/hda2/boot/grub, because previously I used Suse’s Grub to boot all the systems in the box.
Now I have Windows MBR permanently in the first bootable disk but it boots up XP or Grub in the hda2 Fat32 partition which has no operating system.
The only changes to the original hda2 partition are
(1) A new directory \boot\grub
(2) 3 files of stage1, stage2 and menu.lst added
(3) Boot sector is occupied by Grub
I have tried it on 3 computers and the results were dependable.
Implications
(1) More Windows users can install and try Linux because there is no need to lose the Windows MBR.
(2) Another powerful feature of Linux publicised.
(3) Making good use of the empty the boot sector available in a data-only primary partition.