25.04.2014, 04:01 UhrDeutsch | English
Hallo Gast [ Registrierung | Anmelden ]

Installing Grub

(adapted from a thread written by Mipooh Gurb posting

Installing Grub: an easy way

The easiest way to install grub:
# apt-get install grub grub-doc
# grub-install /dev/hda
# update-grub


That will create a menu.lst if you haven't one and also add your kernels. All of them including symlinks. You don't need the multiple entries. Place the entries you don't want changed before or after the "# # # AUTOMAGIC KERNELS LIST" and they will not be changed by update-grub.

*NOTE* Building a kernel the debian way will automatically update-grub.
*OTHER NOTE* If you're using BH08 you'll now need to do apt-get install grub-gfxboot.

Installation of Grub in layman's terms (for non geeks)

The installation of GRUB is in my opinion very easy. After Kano explained it to me, I now can play with GRUB and can say that I feel very comfortable with it.

I will explain here a simple standard install on the first hard drive and assume that:
1) you boot from the first HD; and
2) your Linux is somewhere on this first HD.

(Other configurations are possible, but as they are a bit more complicated, I won't mention them here.
I want to keep the first steps as simple as possible.)

One thing you should know is that Grub counts differently. It starts with 0. So your hda1 would be (hd0?,0) in Grub, therefore, your hdb5? would be (hd1?,4).

To install grub, when you are in the partition where Linux is (which will have the boot information), you just type (as root):
# grub-install /dev/hda


This tells Grub to use the MBR (master boot record) of hda. Grub knows the rest of the stuff it has to write there (from where you activated it).

You could also type:
# grub-install --root-directory=/mnt/hda2 /dev/hda 

instead of the previous command, but that's not necessary.

You would you type that line to tell Grub in which root directory it has to put the information and which MBR it should use only if you cannot get to your linux partition first (and then maybe you would have to do it from the CD).

That's nearly all. One more thing now.

Grub put some files into your boot directory. Don't worry about them, as they are needed, but you just have to know about and use this one:
# /boot/grub/menu.lst 

In the simplest case, you will find in it first the information on how long to wait for GRUB to start and what colours to use.

For example:
timeout 10 
color black/cyan yellow/cyan 


I must say, however, that I never really used this color line, as I always have had from the beginning a "picture" (called bootsplash) on my computer. Maybe I will explain about that later.

The information written in the menu.lst file is: what you want to boot; and where it is. Here is an example: (as many people have Windows and one Linux distribution, I will use an example for Windows on partition hda1 and KANOTIX on hda2?, the simplest case.)

title Windows
root (hd0?,0)
chainloader +1

title Kanotix
kernel (hd0?,1)/boot/vmlinuz-2.4.23-xfs-fe root=/dev/hda2? hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=scsi apm=power-off nomce vga=791

Take care! These are only three lines!
title (how it will appear on you menu when you boot your system)
kernel (information about the kernel file name, where it is and some other information)

For the Windows OS, I believe that what I wrote in my example is enough to do the job. But I will explain the Linux part a bit more.
1. First, you tell Grub the title of your menu.
2. You then put the information about where the kernel to load is to be found. In this case, the kernel is on the second partition of hda in the folder /boot and its name is vmlinuz-2.4.23-xfs-fe.
3. Directly under that you write where the root of your OS is, now you can use the Linux "normal way" of writing disk and partition numbers. In this example root is on /dev/hda2?. Compare that to the first information you gave (hd0?,1) which is hda2?.
4. The next information is about the scsi-emulation for your CDs. In most cases hda and hdb would be used for HD only, but it doesn't do anything bad if hda and hdb or some of the following are not CD or not even exist, as it will be ignored.
5. I forgot what the apm command is used for, even if Kano explained it just yesterday Kano in the #kanotix channel. Its for switching off the apm (whatever that is). Next is for not printing some error messages and the vga=791 is to set the screen's resolution for the messages while booting.

I think that in most cases it can be used as is.
Well, that's it, reboot!

Grub and other distributions

As the previous explanation was specifically for Kanotix, I will tell you what difference you encounter with some other distros:

Some distros need an initrd, or maybe you have a KANOTIX-copy and a boot image (not an install) on your hd, that would need an initrd too. So you just add one line to tell Grub where it is and what´s it´s name. I only have one from my KANOTIX-Copy on my computer, but I know for example that Knoppix would need one.

It is named miniroot.gz here and its located right on /, so I had to type:

initrd (hd0?,0)/miniroot.gz

This would be a extra line after the kernel line and it tells Grub, in this case, that the other boot information is to be found in /hda1/miniroot.gz.

So what you have to look for is what the name of your initrd is, where it is located and add that information to your Grub entry. That should be all.

Once done with that, you can add new installations entries in Grub just by editing the /boot/grub/menu.lst of your install, which carries that information. Grub will always boot taking the first entry from there and then go to the place where the kernel is.

It's no problem if you have more than one hard drive. As long as you boot from hda and have the menu.lst on hda, you can boot whatever you want wherever it is.

If you want to boot from hdb, it will become a bit tricky. So, as that is somewhat more involved, I will explain it in a section below. I only wanted to mention in passing that it's possible too.

Editing colours and background picture

If you don't like the colours or you want to use a background picture you can add this line :
splashimage (hd0?,1)/boot/grub/nameofpicture.xpm

and comment out or delete the colour line already present at the top of your menu.lst.
This says to Grub, use the nameofpicture.xpm as a background and you can find it on /hda2?/boot/grub/nameofpicture.xpm

Of course you must have one there! It has to be a .xpm extension and is limited in colours and so on. Just try out, you can make it with gimp.

If you want to know more, Kano made howtos at GrubBoot_manager, for example....
And maybe, if he has some time for that, he can give us some tricky grub examples.

Installing Grub on a second hard drive

Ok, now lets add a little bit more refinement.

Lets assume that you don't want to boot with hda, but with hdb (as I just do, as a matter of fact).

Now you would have to change some lines in the menu.lst, to "swap partitions" (invert) for win which is in hda here, in order to tell GRUB that hdb is now the first HD.

So for the Windows entry, it would look like this:

title Windows
map (hd0?) (hd1?)
map (hd1?) (hd0?)
root (hd1?,0)
chainloader +1

For your Linux-partitions you also change the notation to swap (invert) the partitions (but not on the line with 'root=hdxx' information - just the lines above)

The example below shows part of the entry for KANOTIX on hdb2? in my Grub menu.lst file:

kernel (hd0?,1)/boot/vmlinuz-2.4.24-xfs-fe root=/dev/hdb2?

As you can see, it looks like the kernel would be on hda2?, as I wrote: kernel (hd0?,1). The reason being that for grub, hdb is now my first hard drive. On the following line, with root=/dev/hdb2?, the notation is "normal" again (Linux notation, and true location). So that line would not have the "swapped drives" like the lines before.

If you have an initrd line, you have to use the swap on that line too, as you did for the map notation. Example:

initrd (hd0?,0)/miniroot.gz

This initrd or miniroot.gz file is on hdb1?, but we use a zero like if it was "a".

It is important to use the MBR of hdb if you make an install like this!
MBR and the other Grub information with the menu.lst have to be on the same hard drive.

So you input the command:
grub-install /dev/hdb

Tricky, but not so difficult after all, isn't it.

Re-installing Grub from a Kanotix CD

To reinstall GRUB from Kanotix cd:

Use the following command:

mount /dev/hda3? /mnt/hda3?
grub-install --no-floppy --root-directory=/mnt/hda3? --recheck /dev/hda


Making a Grub boot floppy

To make a grub boot floppy, see:


http://www.linuxjournal.com/article.php?sid=4622
OR
http://www.yolinux.com/TUTORIALS/LinuxTutorialRecoveryAndBootDisk.html#GRUB
XML Revisions of $tag
Seiten-History :: Letzter Editor : Richard :: Eigentümer : OffTopic ::
Powered by pnWikka 1.0
 
 
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örg 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.