Bootsector overwritten by Windows MBR
We assume there are 2 hard disks in the PC: windows is installed on the first hard-disk, and Joatha is installed on a partition on the second hd, e.g. on hdb5.
Now boot the Live-CD: Open a Terminal and become root with
sudo root
Mount the partition where Joatha is installed (in our example hdb5)
mount /media/hdb5
Now rewrite Grub to MBR:
grub-install --recheck --no-floppy --root-directory=/media/hdb5 /dev/hda
Creating a bootable Floppy
During HD-Installation of Joatha you can create a Boot-Disk. Here you will see how to do so afterwards. You need to do the following steps:
1. Format a floppy
fdformat /dev/fd0
2. Create a filesystem on the floppy (it is advisable to use ext2 or vfat)
mkfs -t ext2 -c /dev/fd0u1440 or mkfs.vfat /dev/fd0u1440
3. Mount the floppy
# mount /dev/fd0 /floppy
4. Create directory tree on the floppy
mkdir -p /floppy/boot/grub
5. Copy the needed files to the floppy
cp /boot/grub/stage1 /floppy/boot/grub cp /boot/grub/stage2 /floppy/boot/grub
6. To be able to start the right OS (Joatha) from the right partition, you finally must do as follows:
7. Copy the "menu.lst" file, that was written by Joatha to the /boot-directory of the Joatha-Partition onto the floppy
cp /boot/grub/menu.lst /floppy/boot/grub/menu.lst
8. Unmount the floppy (note the the spelling of the command carefully)
umount /dev/fd0
9. Start the Grub-Shell to finish the re-installation of Grub. To do so, type:
grub grub> root (fd0) grub> setup (fd0) grub> quit
We have now created a bootable floppy, from which we can reliably boot Joatha.
If you need to create the floppy from a running Live-CD, the procedure is a bit different. Let's assume, Joatha is installed on partition /dev/hda5, then in addition you have to do instead of step 7
10. Mount the Joatha Partition
mount /dev/hda5 /media/hda5
11. Copy the "menu.lst"-file, that was written by Joatha to the /boot-directory of the Joatha-Partition onto the floppy
cp /mnt/hda5/boot/grub/menu.lst /floppy/boot/grub/menu.lst
12. Unmount the Joatha Partition (note the spelling of the command carefully)
umount /dev/hda5
The rest is similar to steps 8 and 9 in the first case.
Removing grub from MBR
It's very simple: as root enter
lilo -M /dev/hda -s /dev/null
in a terminal.
GRUB the Boot Manager - what it is
General
Grub is a boot manager that can boot operating systems from different partitions. Grub does not rely on block lists to find the needed files for a system to start up, and it can read a bunch of file-systems by default: ext2, ext3, reiserfs, ... (Linux), Fat32, Fat16 (Windows), UFS (BSD), Minix and many others.
Grub knows BIOS-extensions (meaning it can boot partitions above 8 GByte!) and has no 1024-cylinder-barrier. Grub doesn't really care, where the kernel physically resides, all it needs is the declaration of the partition and the path to the kernel it's supposed to boot (this can even be a symlink). After a change in the configuration (i.e. the menu.lst) it doesn't need a program-call like Lilo does, the new configuration is applied at next boot.
Joatha uses Grub to boot from CD, and when installing to harddisk, Grub is used by default. Nonetheless Grub can be installed afterwards without a problem. Grub is installed to the MBR from a root-shell with the following command:
grub-install --root-directory=/media/hdaX /dev/hdY
/media/hdaX stands for the readable-mounted partition, on which, in the directory "/boot/grub" the necessary files (stage2, stage1_5xxx) will be placed. The configuration file "menu.lst" must also be created in that directory. /dev/hdY is the harddisk, in whose MBR Grub will be installed, normally /dev/hda.
Drivenames/Devicenames
Grub does not differentiate between SCSI- and IDE-Harddisks. (hd0) is always the first hard disk that is first in the boot sequence (setting in BIOS), no matter if IDE or SCSI. Unusual is the counting method; the first partition on the first hd is (hd0,0). Primary partitions are numbered from 0-3, logical partitions count from 4 on up.
| Grub | Linux | Label |
|---|---|---|
| (fd0) | /dev/fd0 | Floppy (under Windows) |
| (hda0) | /dev/hda | first hd |
| (hd0,0) | /dev/hda1 | Part.1 on hd1 |
| (hd0,5) | /dev/hda6 | Extended. part. on hd 1 |
All nominations for devices for Grub are to be put in brackets (). Be aware of the entries behind the Kernel-line though. In contrast to Grub the Kernel needs the data in the normal linux way. The entries in the following example both point to the same partition, namely the fourth partition on the first hd. The first line is in Grub notation, the second one in typical linux notation:
root (hd0,3) kernel /boot/vmlinuz root=/dev/hda4
Command-Mode (Grub-Shell)
A very comfortable feature is the Command-Mode. It is accessed by "c", and here comes the Grub-Shell. This enables you to find and boot different systems and files (i.e. Kernel) even with a faulty menu.lst.
To do a little bit of testing, you can even run Grub from a booted system from within a root-shell with "grub". In the Grub-Shell you can see all possible commands with "help". Detailed help for each command is obtained with help command", back to the Linux-Shell you go with "quit"( Grub-Shell is terminated). In the Grub-Shell the tab-key has a similar function as in the Linux-Shell, which is a great ease. Commands, Drivenames and Filenames can be auto-completed with the tab-key.
Grub gives you the opportunity to locate the Kernel and the initrd even before the actual boot by "find" , e.g.with the following command
find /boot/vmlinuz
Grub shows the partitions, that have a Kernel with the name "vmlinuz" in the directory "/boot":
(hd0,3) (hd1,0)
All available partitions can be found with "geometry", e.g.
geometry (hd0)
shows this:
"drive 0x80: C/H/S = 3648/255/63, The number of sectors = 58605120, /dev/hda Partition num: 0, Filesystem type is fat, partition type 0xb Partition num: 1, Filesystem type is fat, partition type 0xb Partition num: 2, Filesystem type is fat, partition type 0xc Partition num: 4, Filesystem type is ext2fs, partition type 0x83 Partition num: 5, Filesystem type unknown, partition type 0x82 Partition num: 6, Filesystem type is fat, partition type 0xb"
After the Kernel or an existing initrd (or miniroot.gz) has been found, you can start with "boot".
Edit-Mode
This mode enables you to change entries in the "menu.lst" while booting. This works even when Grub is booted from CD an the menu.lst is write-protected . To do so you first hit ESC, confirm with Return and then hit "e". The parameters are then added to the end of the line or you move within the line with the Cursor-keys.
menu.lst (examples for possible entries)
Lines with comments are started with # and don't interfere with the bootprocess, so they can stay in the file.
# Example /boot/grub/menu.lst ################################################ # setkey changes the keyboardlayout to german setkey y z setkey z y setkey Y Z setkey Z Y setkey equal parenright setkey parenright parenleft setkey parenleft asterisk setkey doublequote at setkey plus bracketright setkey minus slash setkey slash ampersand setkey ampersand percent setkey percent caret setkey underscore question setkey question underscore setkey semicolon less setkey less numbersign setkey numbersign backslash setkey colon greater setkey greater bar setkey asterisk braceright # sets time in seconds, after that automatic boot will be conducted. # inbetween you can call Edit- or Commandmode with "e" or "c". timeout 30 # sets the Default-System that is booted after the timeout default 0 # remembers the partition that was booted last, if "savedefault" is set under Title #default saved # is booted, when booting of the default-entry fails fallback 1 # set foreground/background colours # options:flashes red background: blue color white/blue blink-red/blue # entry 1 is default 0 and boots e.a.. Windows 98 ################# title Windows 98 (partition 1 o?n disk 1) rootnoverify (hd0,0) makeactive chainloader +1 # entry 2 is default 1 and boots e.a. Windows 2000 ################# title Windows 2000 (partition 2 o?n disk 1) rootnoverify (hd0,1) makeaktive chainloader /bootsect.dos # entry 3 is default 2 and boots Suse ################## title Suse-Linux root (hd1,5) kernel /boot/vmlinuz root=/dev/hdb6 read-only # other parameters are possible i.e.: # kernel /boot/vmlinuz root=/dev/hdb6 single kernel /boot/vmlinuz root=/dev/hdb6 vga=ask # entry 4 is default 3 and boots Debian ################## title GNU/Debian (first extended partition o?n disk 2) root (hd1,4) kernel /boot/vmlinuz root=/dev/hdb5 read-only # entry 5 is default 4 und boots DOS from disk ################## title DOS (partition 3 o?n disk 1) root (hd0,2) makeactive chainloader +1 # entry 6 is default 5 und boots from floppy ################## title floppy chainloader (fd0)+1
Dual and Multiple Booting
Some people need/want several Windows-Installations. Windows always wants to boot from disk 1. We will have to hide one partition and activate another. The following commands should be entered in the GRUB-Commandline and, if successfull, copied to the menu.lst. This should be done for every Windows-partition. Don't forget to do a Backup! ;-)
hide (hd0,0) # hidden partition 1 of disk 1 unhide (hd0,1) # makes partition 2 of disk 1 visible rootnoverify (hd0,1) # makes partition 2 of disk 1 the Root-FS makeactive # makes partition 2 of disk 1 aktiv chainloader +1 # points to the first sector of the start-partition boot # boots the operating system
If you want to start a 2nd Windows from the 2nd disk, you virtually swap disk 1 and 2. Thereby Windows sees a simulated 1st disk:
map (hd0) (hd1) map (hd1) (hd0)
Pitfalls
As Grub has no 1024-cylinder barrier and can boot systems above 1024 cylinders, the "/boot/grub/stage2" must be accessible by the bios (must be before 1024 cylinders). Stage2 may not be moved after installation (e.g. Defrag could try that). Setup data will get written that would not be congruent anymore. It is reasonable to make stage2 read-only (you must be in the current directory):
Dos: attrib +r +s stage2 LINUX: # chmod a -w ./stage2
Where to find out more
Get a Grub-Floppy-Image. (ca. 580 kB) and play around a bit. On the floppy you also find a functioning FreeDOS and an editor. If you remove the write-protection from the disk, you can edit the menu.lst on the floppy to your needs.
If you have a supported network card, Grub can boot over the network. An appropriate Boot-Disk can be obtained here (allthough with an older version of Grub).

