PDA

View Full Version : HOW-TO: Dual-boot using "grubinstall"



eco2geek
08-20-2004, 02:07 AM
How to use Topologilinux's "grubinstall" to dual-boot WinNT/2K/XP and Knoppix


What?
This how-to shows you how to install a special Windows version of GRUB, written by the creators of Topologilinux, to dual-boot Windows 2K/XP (installed on an NTFS-formatted partition) and a hard disk install of Knoppix. (It can also be used to dual-boot any version of Linux, as well as a "poor man's install" of Knoppix.)


Why?
This version of GRUB loads after Windows' existing bootloader, "NT loader" (hereafter abbreviated "NTLDR"). In other words, first you'll get an NTLDR screen asking which OS you want to boot. If you choose Linux, then GRUB comes up. It doesn't change your MBR.

If you install GRUB or LILO when you install Knoppix, there's always the risk that something will go wrong and your Windows partition will be rendered unaccessible. This method greatly reduces that risk, since it doesn't change the existing MBR.


Where to get it?
It can be downloaded from here:
http://hem.passagen.se/svto/tlinux/files
-- get "grubinstall-1.0.zip". Or you can get it by downloading the entire first CD of the Topologilinux 4.0 2-CD set, but the version on hem.passagen.se is newer.

There are some other differences between the two versions, most notably that "ntfsinstall.exe" in the CD version is named "grubinstall.exe" in the newer version, and you don't get an "install.bat" file or a sample "menu.lst" with the newer "grubinstall-1.0.zip" package. This how-to uses the files from the newer "grubinstall-1.0.zip" package, rather than the version on the Topologilinux 4.0 CD.


What are its limitations?
Grubinstall uses a file, "stage1", that needs to be on the same partition as NTLDR. In other words, you have to put it on your "C" drive.
Grubinstall's "stage1" and "stage2" files cannot be on a compressed volume, nor can they be individually compressed by Windows. The most common reason for this version of GRUB not working is that people try to install it on compressed drives.
If you defrag your Windows partition, you have to reinstall this version of GRUB.
It only works on NTFS-formatted partitions (NTFS = "NT File System", the default for Win2K/XP), not FAT32.
You must have Administrator rights to install it.

How to install it?
You should always have a backup before you (re-)partition your drive(s) or install any boot loader.
You need to already know how Linux refers to hard disk partitions, or it's not going to make much sense.
Start by reading the files (install.txt, readme.txt and faq.txt) inside the grubinstall package. Also read the GRUB manual at http://www.gnu.org/software/grub/manual/html_node/ in order to get a sense of how GRUB works and how to write a "menu.lst" file ("menu.lst" is the name of GRUB's configuration file).
What follows is all based on the assumption that your copy of Windows is installed on the first primary partition on the master hard drive (or the only hard drive, if you've only got one) on your primary IDE channel, which is formatted as NTFS. It's known to Windows as your C: drive, to Linux as hda1, and to GRUB as (hd0,0).
You will need to log on to Windows with administrative rights to do this.
Make a directory named "boot" at the root level of your C drive (i.e. C:\boot) and copy the files from grubinstall-1.0.zip to it.
Create a "menu.lst" file in C:\boot that will tell GRUB how to boot Knoppix (see below for examples).
Now you should now have (at least) the files "menu.lst", "stage1", "stage2", and "grubinstall.exe" in C:\boot.
Make a backup of C:\boot.ini. (C:\boot is a good place to store it.)
Unset/clear the "read-only" attribute on C:\boot.ini (you can do this in Windows Explorer by right-clicking on it and selecting "Properties" from the context menu) in order to make it editable. Open it in Notepad by double-clicking on it. Add the line

C:\boot\stage1="Knoppix 3.4"

to the bottom of boot.ini. Save it and reset the "read-only" attribute.
Pull up a command prompt, navigate to the C:\boot directory, and run the following command:

grubinstall -d C:

Reboot your computer. Windows' NTLDR should now give you a boot screen allowing you to choose between Windows and Knoppix. When you choose Knoppix, the GRUB boot screen should come up, and once you make a selection there (or let it default to the first entry), it should boot Knoppix. If it all works as it should, congratulations! You're done.
If it doesn't work as planned, reboot with Ctrl-Alt-Del, boot back into Windows and make sure C:\boot\menu.lst (the GRUB configuration file) is correct. You do not need to rerun grubinstall.exe after you change "menu.lst". (You can also edit your GRUB commands from within GRUB itself, but your changes aren't automatically saved.)


Setting up GRUB's menu.lst:

First, some GRUB terminology. GRUB refers to hard disk partitions as follows:


GRUB Linux equivalent
(hd0,0) /dev/hda1
(hd0,1) /dev/hda2
(hd0,2) /dev/hda3
(hd0,4) /dev/hda5
(hd1,0) /dev/hdb1
(hd1,1) /dev/hdb2
(fd0) /dev/fd0
(cdrom) /dev/cdrom

The parenthases ( ) around the partition names are required.

Lines that start with the pound sign # are comments and are ignored.


Sample menu.lst #1:
Win2K on hda1; Kanotix Bug Hunter 5 (a Knoppix variant)'s / (root) partition on hda2.
Kanotix has 2 kernels (2.4 and 2.6) installed, and GRUB allows you to choose between them.
"hdc" and "hdd" are CD-R drives (thus the "hdc=scsi" and "hdd=scsi" parts).
The "vga=733" line tells Kanotix/Knoppix to use a text-mode resolution of 1024x768. If you don't like that, or if that doesn't work for you, try "vga=normal".


# ---begin menu.lst---
# --------------------------------------------
# menu.lst - GRUB boot menu configuration file
# --------------------------------------------

# Boot automatically after 15 seconds
timeout 15

# By default, boot the first entry
default 0

# Fall back to the third entry (back to Windows) if GRUB can't boot the first entry
fallback 2

# Pretty colors
color cyan/blue white/blue

# For booting Kanotix (kernel 2.6)
title Kanotix v05/2004 (kernel 2.6)
root (hd0,1)
# Note: /boot/vmlinuz is a symlink to the 2.6 kernel
kernel /boot/vmlinuz root=/dev/hda2 vga=773 ro hdc=scsi hdd=scsi
boot

# For booting Kanotix (kernel 2.4)
title Kanotix v05/2004 (kernel 2.4)
root (hd0,1)
kernel /boot/vmlinuz-2.4.26-mppe-ar root=/dev/hda2 vga=773 ro hdc=scsi hdd=scsi
boot

# For booting Windows 2K
title Back to the Windows 2K boot menu
rootnoverify (hd0,0)
makeactive
chainloader +1

# ---end menu.lst---


Sample menu.lst #2:
WinXP on hda1; Knoppix 3.4's / (root) partition on hdb2.
Knoppix has 2 kernels (2.4 and 2.6) installed, and GRUB allows you to choose between them.
"hdc" is a CD-R.


# ---begin menu.lst---
# Boot automatically after 20 seconds
timeout 20

# By default, boot the first entry
default 0

# Fall back to the third entry (back to Windows) if GRUB can't boot the first entry
fallback 2

# Pretty colors
color cyan/blue white/blue

# Boot Knoppix 3.4 (kernel 2.6.5)
title Knoppix v3.4 (kernel 2.6.5)
root (hd1,1)
kernel /boot/vmlinuz-2.6.5 root=/dev/hdb2 vga=773 ro hdc=scsi
boot

# Boot Knoppix 3.4 (kernel 2.4.26)
title Knoppix v3.4 (kernel 2.4.26)
root (hd1,1)
kernel /boot/vmlinuz-2.4.26 root=/dev/hdb2 vga=773 ro hdc=scsi
boot

# Boot Windows XP
title Windows XP boot menu
rootnoverify (hd0,0)
makeactive
chainloader +1

# ---end menu.lst---


Sample menu.lst #3: "Poor man's install" of Knoppix. No CD necessary after installation.
The ~700MB (cdrom)/KNOPPIX/KNOPPIX file has been copied to the /KNOPPIX dir on hda2 (hda2 is an ext2 partition)
Persistent home is on a thumbdrive (/dev/sda1)
Saved configs are on a floppy
Kernel and miniroot files from the CD are saved in C:\knoppix on the NTFS partition (!)
"hdc" and "hdd" are CD-R drives
Note: This can be combined with the sample menu.lst files above.


# ---begin menu.lst---

# Boot automatically after 5 secs.
timeout 5

# Pretty colors
color cyan/blue white/blue

# By default, boot the first entry
default 0

# Fall back to the second entry (back to Windows) if GRUB can't boot the first entry
fallback 1

# For booting Knoppix off the hard disk
title Boot Knoppix 3.4 (kernel 2.6) from hard disk
# Requires kernel (linux26) and miniroot (minirt26.gz) in C:\knoppix
# Requires configs from floppy and persistent home from thumbdrive (aka /dev/sda1)
# Note how the Knoppix "cheatcodes" can be put here (The next line is all one line, not two!)
kernel (hd0,0)/knoppix/linux26 fromhd=/dev/hda2 lang=us keyboard=us alsa hdc=scsi hdd=scsi vga=791
floppyconf home=/dev/sda1/knoppix.img
initrd (hd0,0)/KNOPPIX/minirt26.gz

# For booting Windows 2K/XP
title Back to Windows 2K/XP
rootnoverify (hd0,0)
makeactive
chainloader +1

# ---end menu.lst---


Final note: All this sounds harder than it really is. Standard disclaimers apply: If this causes your computer to burst into flames, or erases your hard drive, don't come looking for me (or the author of grubinstall).

[Edit: Get rid of stray slash]

mzilikazi
08-20-2004, 02:29 AM
Well I've always wondered about NTLDR and any antivirus software you might have on a winbox. If the antivirus software is configured to scan the boot sector does it get upset if it finds that NTLDR is gone? If so I suppose this would be a very good idea.

The only winboxen I have to maintain don't dual boot as I also have Linux boxes handy and therefor it is simply unnecessary to dual boot.

That's a nice looking howto BTW.

eco2geek
08-20-2004, 07:02 AM
Thanks. One of these days I'll get a Linux-only computer that's faster than 500MHz. :wink:

Turns out version 1.01 of grubinstall is available on the author's website (http://geocities.com/lode_leroy/grubinstall/).

pkoufalas
11-30-2004, 03:37 AM
Hi eco2geek,

Thanks for that how-to. I followed the process and it worked, mostly.

I got a Grub prompt instead of a menu. I could type in root (hd0,2), kernel /boot/vmlinuz-2.6.7 root=/dev/hda3 boot and Knoppix was off and running.

However, to see the menu I had to move menu.lst from C:\boot to /boot on /dev/hda3, my root partition.

When I tried in Grub to set root (hd0,0) and do find /boot/menu.lst I didn't get happy results. It didn't recognise the NTFS parition type; and it couldn't find menu.lst. When I moved menu.lst to /boot in /dev/hda3, it could find it okay and returned (hd0,2).

When doing grubinstall -d C: -1 C:\boot\stage1 -2 C:\boot\stage2 -m (hd0,0)/boot/menu.lst I didn't see anything strange returned; it mounted NTFS okay and the path to menu.lst looked good. I just couldn't get it to load the menu. I then re-did grubinstall with -m (hd0,2)/boot/menu.lst and it was fine.

Prior to all this, when preparing I noticed that XP SP2 complained after I repartitioned /dev/hda1 to make room for swap and root. It checked and fixed whatever it was unhappy about and then things looked fine.

I doubt it's related, but during the Knoppix hd install, I couldn't opt out of installing lilo or grub, so I just allowed the installer to install lilo on the /dev/hda3 partition.

I'm posting this more out of interest than anything; it all seems to work okay with menu.lst on my linux root partition under /boot.

Now, if I could only change the language from German to English... :)