22.11.2014, 16:44 UhrDeutsch | English
Hallo Gast [ Registrierung | Anmelden ]

kanotix.com FAQ (h酳fig gestellte Fragen)

Kategorie: Index -> Bootmanager - Grub -old!-

Frage

Antwort

What is the Grub-Bootmanager?

General

Grub is a bootmanager that can boot operating systems from different partitions. Grub does not rely o要 blocklists to find the needed files for a system to start up, and it can read a bunch of filesystems 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 knows no1024-cylinder-barrier. Grub doesn't really care, where the kernel physically lies, 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.
KANOTIX 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 intalled to the MBR from a root-shell with the following command (for KANOTIX's version 2005-03 or older use mnt instead of media):
# grub-install --root-directory=/media/hdaX /dev/hdY

/media/hdaX stands for the readable-mounted partition, o要 which, in the directory "/boot/grub" the neccessary files (stage2, stage1_5xxx) will be placed. The configurationfile "menu.lst" must also be created in that directory. /dev/hdY is the harddisk, in whose MBR Grub will be installed, normaly /dev/hda.


Drivenames/Devicenames

Grub does not differentiate between SCSI- and IDE-Harddisks. (hd0) is always the first harddisk that is first in the bootsequence (setting in BIOS), no matter if IDE or SCSI. Unusual is the counting method; the first partitioin o要 the first hd is (hd0,0). Primary partitions are numbered from 0-3, logical partitions count from 4 o要 up.

GrubLinuxLabel
(fd0)/dev/fd0Floppy (under Windows)
(hda0)/dev/hdafirst hd
(hd0,0)/dev/hda1Part.1 o要 hd1
(hd0,5)/dev/hda6extended. part. o要 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 o要 the first hd. The first line is in Grub-notation, the second o要e 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 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 dont 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要 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要 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要 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要 disk 1)
root (hd0,2)
makeactive chainloader +1
# entry 6 is default 5 und boots from floppy
##################
title floppy
chainloader (fd0)+1


Booting from secondary disk:(e.g. several Windows-Installations)

Some people need/want several Windows-Installations. Windows always wants to boot from disk 1. We will have to hide o要e partition and activate another. The following commands should be enterd in the GRUB-Commandline and, if successfull, copied to the menu.lst. This should be done for every Windows-partition. Dont 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

Grub knows no 1024-cylinderbarrier and can boot systems above 1024 cylinders. However, "/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't 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


Have you gotten interested?

... then get a Grub-Floppy-Image here(ca. 580 kB) and play around a bit. O要 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 o要 the floppy to your needs.

The official FAQ for Grub is found here.

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

nach oben
Windows overwrote my Bootsector. How can I reinstall Grub?

We assume there are 2 harddiscs in the PC: windows is installed on the first harddisc, and KANOTIX 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 Kanotix 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

(for KANOTIX's version 2005-03 or older use mnt instead of media)

That's it!

nach oben
I don't want to/can not/may not install Grub to the MBR. Can I create a bootable Floppy after installation?

During HD-Installation of KANOTIX you can create a Boot-Disc. 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 directorytree 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 (KANOTIX) from the right partition, you finally must do as follows:
7. Copy the "menu.lst"-file, that was written by KANOTIX to the /boot-directory of the Kanotix-Partition onto the floppy
# cp /boot/grub/menu.lst /floppy/boot/grub/menu.lst
8. Unmount the floppy
# umount /dev/fd0
9. Start the Grub-Shell to finish the reinstallation 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 KANOTIX.

If you need to create the floppy from a running Live-CD, the procedure is a bit different.
Let's assume, KANOTIX is installed on partition /dev/hda5, then in addition you have to do instead of step 7
10. Mount the KANOTIX Partition
# mount /dev/hda5 /media/hda5
11. Copy the "menu.lst"-file, that was written by KANOTIX to the /boot-directory of the Kanotix-Partition onto the floppy
# cp /mnt/hda5/boot/grub/menu.lst /floppy/boot/grub/menu.lst
12. Unmount the KANOTIX Partition
# umount /dev/hda5
The rest is similar to steps 8 and 9 in the first case.

(for KANOTIX's version 2005-03 or older use mnt instead of media)

nach oben
I would like to remove grub from the MBR, what should I do?

It's very simple: as root enter

# lilo -M /dev/hda -s /dev/null

in a terminal.

nach oben
 
Deutsch | English
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is 2004 - 2006 by J顤g Schirottke (Kano).
Consult Impressum and Legal Terms for details. Kanotix is Free Software released under the GNU/GPL license.
This CMS is powered by PostNuke, all themes used at this site are released under the GNU/GPL license. designed and hosted by w3you. Our web server is running on Kanotix64-2006.