Note that although GRUB and Linux are capable of dealing with
installations in extended partitions, here we show a preference for
using primary partitions whenever possible. Filesystems in primary
partitions are often mountable by other operating systems, whereas
cross-OS mounting filesystems in extended partitions is often not
supported.

This system has two hard disks with six different operating
systems using seven partitions. As you probably know, each OS has
its own nomenclature for naming devices and partitions. For
example, the Slackware installation would be known to Linux as
/dev/sda2 (with swap on /dev/sda4), while FreeBSD would recognize
its filesystem on /dev/da1s1a. Alternatively, if the system were
configured with IDE hard disks, Slackware would be on /dev/hda2,
and FreeBSD would refer to its root directory on /dev/ad1s1a. You
get large helpings of this alphabet soup whenever maintaining any
multiboot setup.

Since GRUB also needs to be capable of loading any of these
systems, it has its own OS-neutral naming conventions for referring
to devices. Hard disks are all hd, floppy disks are fd, device
numbering starts from zero, partition numbering starts from zero
and complete device names are enclosed in parentheses.

With these naming rules, the floppy disk is (fd0), the Win98
partition is (hd0,0), and GRUB recognizes the Slackware and Debian
partitions respectively as (hd0,1) for slackware and (hd0,2) for
debian.

The BSDs further subdivide their own partitions (or
“slices” in BSD terms), and GRUB would refer to the root mount
for the FreeBSD system on (hd1,0,a).

Okay, ready to give GRUB a taste? Slide the GRUB floppy in
the drive and reboot your system (with your system's BIOS
configured to boot from A: drive). You should see GRUB's terse boot
messages and then find yourself in the GRUB command-line
environment as shown in Figure 1.

To start, let's boot Slackware. Enter the following commands
at the grub prompt:

Badda-bing, badda-boom, that postage-stamp-sized Tux appears
in the upper-left corner of your screen (yes, Slackware is
configured to use the framebuffer device), and Linux bootstraps its
jolly way into glorious being.

Another example. Reboot the system again with the GRUB
floppy, and enter the following commands at the grub prompt:

Now your screen turns into a vague blue cloud, and you think
you have made some horrible mistake. Then you realize it's only
Windows and you remind yourself to expunge this partition one day
soon.

Let's take a closer look at these examples. In the Slackware
boot, we first used the GRUB root
command to specify the device for GRUB to access. If the device has
a filesystem recognized by GRUB (that is, one of ext2fs, reiser,
ffs, etc.), it attempts to mount it and get its partition
information, then reports its success following the command. Thus,
you would see the following command/response dialog on your
screen:

grub> root (hd0,1)
Filesystem type is ext2fs, partition type 0x83

Next, we used the GRUB
kernel command to specify the boot
image for GRUB to load. The argument to the kernel command is the
filename of the boot image relative to the device specified by the
root command above. The kernel image file can also be specified in
explicit (device)/filename terms as follows:

grub> kernel (hd0,1)/vmlinuz

The kernel command gives you great flexibility for specifying the
boot image you wish to load. For example, if we saved a previous
version of a kernel to the file /vmlinuz.old, we could specify it
with this command (which shows GRUB's response):

The arguments following the name of the boot image are passed to
the target kernel and aren't related to GRUB. For Linux, these
kernel arguments are pretty much what you would specify them to be
in lilo.conf. In our example, we tell the kernel what device to
mount for the root partition (root=/dev/sda2 ro), using the device
nomenclature expected by Linux. Note here that we also use the
ro flag to mount the root
filesystem read-only initially while it performs its filesystem
check. The other kernel argument in our example simply demonstrates
setting another kernel variable (vga=791) to use a particular vga
mode for the framebuffer display.

Finally, the last command is grub>
boot. The kernel image specified is now loaded and sent
rolling down the royal road to bootdom.

The second example, using Win98, demonstrates the use of
GRUB's chain-loading mechanism. This method of booting loads the
target OS's own boot-chain-loader rather than a kernel image of the
OS. In this instance, we specified:

grub> rootnoverify (hd0,0)
grub> chainloader +1

First, the rootnoverify
command is for OS filesystems not specifically recognized by GRUB,
so that GRUB will not try to mount the partition. Next, the
chainloader command will use the first sector of the partition of
device (hd0,0) and attempt to boot whatever it finds there. This is
a common means of booting OSes that install their own boot loaders
in the first sector of the partition where they are installed (this
is sometimes called the partition boot sector or PBR).

Finally, the makeactive
command sets the active flag in the partition table for the device
specified by the root command, as some operating systems, like
Win98, require.

The GRUB command line is easy and fun, and you should boot
the different OSes on your system a few times to get the hang of
it. While you are testing, be sure to keep any notes specific to
getting your particular kernels successfully loaded. This
information will be useful later when you configure the menu system
of GRUB to perform these command-line steps automatically.

But before we leave the command line, here are a few more
GRUB commands to look at.

The help command will
display a list of the 40 or so commands available in GRUB. Typing
the name a particular command after help will produce on-line help
for that particular command. So grub> help
kernel will tell you all about using the kernel
command.

The cat command can be used
to view the contents of a file. For example, grub> cat
(hd0,2)/etc/fstab will show the contents of the
/etc/fstab file in the Debian installation. This is a very handy
way of pulling out system configuration information if your normal
boot loader gets whacked. Note also as you are using the GRUB
command line that, like bash, up and down arrows will scroll
through command history, and a tab will complete the name of a GRUB
command or filename.

Finally, you can call up a specific menu interface with the
configfile command as in:

grub> configfile (fd0)/boot/grub/menu.lst

This will switch GRUB into its menu mode with an interface
defined by the file, menu.lst. We haven't created that file yet,
but—look out, segue coming!—that's exactly what we will do next.

Comments

Comment viewing options

Thanks for sharing your experience with us. Helps me in my quest of migrating from lilo.
Also, this part made my day: "Now your screen turns into a vague blue cloud, and you think you have made some horrible mistake. Then you realize it's only Windows and you remind yourself to expunge this partition one day soon." :-D

I used to have two Operating system Windows XP and RHEL5 in my system. it was working fine but after reinstalling Windows XP i could not boot into the RHEL5. Can any one tell me the solution how can i get back my RHEL5.I can see the partition assigned for RHEL5 at disk management.

I just installed the new version of Fedora on my laptop, on which originally there was only one partion with Vista before. I resized the Vista partition and installed Linux.
Linux works fine, but when I try to boot Vista, it opens the sistem recovery options menu, without being able to do anything. After the end of each option it boots again, giving the two options between linux and "other" and if I choose "other" it goes back to the recovery menu. Do you have any suggestions? I back-up everything I had on the Vista partition, but don't have with me the Vista installation cd at the moment.

I have changed disks from basic to dynamic in my vista
then after rebooting got grub command line (i have managed to get it boot vista) but..i can only access disc C: all other partitions (or volumes after change to dynamic) are gone and i am not sure how to get them back. anyone can help?

I have Lenovo laptop. It has two OS, 1 is Window XP and other is Fedora. By default run Windows XP. These combinations are performing well. But today I have seen a problem. When my laptop is turning on it show GRUB> in black background screen. I didn’t do anything except my laptop turn off using power switch. Is there any solution that I skip it and access XP or Fedora OS. Please help me as soon as possible.

This is probably not good. First, you shouldn't shutdown your computer
by turning off the power switch, you should tell the O/S (XP or Fedora) to
shutdown the system and let the O/S turn off the power when it's through with
its shutdown procedure. If for some reason the shutdown hangs, then,
and only then, use the power switch.

That said, it sounds like your grub installation got damaged somehow,
which probably means your Fedora installation is damaged but that your
Windows installation is ok.
First, try to boot Windows. At the grub prompt do:

Fedora may be a bit trickier since it probably has a damaged file system.
In the above list of partitions, find the first partition
that's not ntfs and assume that's your Linux partition, then do:

grub> root (hd0,YOUR-LINUX-PARTITION-NUMBER)
grub> setup (hd0)

If that by chance succeeds, reboot the system and see if you get
the normal grub screen, if you do, try booting Fedora.
If it doesn't succeed or if it does but it won't boot, and it probably won't,
then you're going to have to boot from a Rescue CD or Live CD and attempt to
repair your Linux install.
The exact steps are going to depend on your exact configuration,
but you want to try to run fsck on your Linux partitions
and possibly re-install damaged files from your backup
(you do have a backup, right?).

Thanks for the two line fix! After my RAID mirror degraded with the loss of one drive, the other drive only booted to the grub> prompt. By reading your section on Fedora, I was able to reboot and now it will autoboot to Fedora again. Time saved, lesson learned. Thanks again...

I have installed Linux EL4 64 bit over Windows Xp on the same hard disk and as expected i wasnt able to boot windows XP. After reading your comment i tried grub> root (hd0, PRESS-THE-TAB-KEY
it is showing File tyoe is unkonwn for windows partitions.

I assume that when you say Administrator you mean root. You have to be logged in or running the editor as root. If that is the case and you can't save the file then make sure that the file is writable. Go to the directory where the file is and run "chmod +w menu.lst" from a command/shell prompt. If you still can't save the file then it could be that the partition is mounted read-only, but that seems unlikely.

I suppose another possibility might be that you have some more sophisticated Linux security system installed, that doesn't make root quite as super of a super-user, but that also seems unlikely.

Hai every one...
When i startup my linux server it shows that /raj(mount point direcotry) is checking filesystem error..it automatically enter into mainitaince mode(repair-system) prompt..I solved this problem using command fsck /dev/sdb5 after i tried to reboot the system it was not able to bootup my linux server.It's showing into Grub> prompt...can any one give solution for this

when i follow all your steps in using grub in windows vista i get "Booting 'Windows vista'

acpi
vista loader 2.0.0

guys what shall i do, i have used windows vista for some time but the problem is that it failed me on the way so i decided to install xp it failed because it cant find the harddrive,i tried linux also failed then how did i get grub because linux failed to install too.i reinstalled windows vista ultimate again it installed well and asked for the administrator i entered the password and computer name but when it tried to boot for the last time it gave me this "booting 'windows vista'
acpi
vista loader 2.0.0

Please help.
I have Xp installed on the master hard drive and the ubuntu on the 2nd hard dive. The 1st hard dive got infected by viruses and wiped ou everything and reintall XP without touching the 2nd hard drive (the slave HD). Now I have my XP runnig but i can't see the ubuntu anywhere, neither I see the second hard dive. I was told to install the grub but i don't know how to proceed . can somebody help/ please I am still abeginner in learning ubuntu I have no clue at all please be specific in your answers

Yes I have the same problem, Minimal Bash-Like (Something Like that)... Anyway i will get to the point... it is because your son has installed linux onto your windows vista or xp computer... If you try recovery disk it will not work or if you have an acer computer it still will not work if you press Alt + F10, as the technicians if you ring up they will tell you to try recoverying the computer but the easiest way is to grab the Cd of the linux and it will take a while to load... then press "LIVE CD", go to the partition editior and try to recover if it still does not work then download this onto a usb and press F12, when the computer starts ( NOT WHEN GRUB IS ON )... Here is the link that you need to extract and move the file onto the usb on another computer (Library or Friends).... Here It Is: http://www.freedownloadscenter.com/Utilities/Misc__Utilities/Linux_File_...

Then Press Download... I had the same problem and it worked like that... if problem still happens buy a later edition of windows vista and put the computer into your room because if your son still has the disk then things can get a little nifty on the new computer because he only needs to press F12 and startup the disk and install it and delete partitions in the live cd...

When I prepare the floppy and
sudo cp -pPv /usr/lib/grub/i386-pc/stage* /media/floppy/boot/grub
the files state1 and stage2 copy over properly but stage2_eltorito copies over as stage2-e.
I presume this truncation is because of the msdos format. Should I try vfat or does it not matter?

When I boot with the grub floppy, stage2 runs and I get a grub prompt.
I then issue: "root (hd0,0)"
but this does not give the expected informational message like
"Filesystem type is ext2fs, partition type 0x83".

I then issue: "kernel (hd0,0/boot/vmlinuz)" and "boot"
and the system appears to start but ends up in the kernel panic.

Does the fact my drives are sata make any difference? I tried "root (sd0,0)" but got an error.

My vmlinuz is a soft link to vmlinuz-2.6.22-14-generic in /boot and I tried the longer name many times but got tired of typing it.

I am able to view a file with something like "cat (hd0,0)/etc/fstab"

Since grub is installed on this system it can boot normally without a grub floppy but I'm testing the process on this computer.

I had Windows Vista on my Laptop with 120 GB HDD Capacity.
Windows partition is of 15 GB. I installed Red Hat Linux with Dual bootloader in Next 15 Gb. The other space on Hard drive was free. I formatted 20 GB for my work on Windows.
Now when i restart , i dont get the Grub Menu and it shows me prompt.
If i give few commands i can get into both of this operating system but the default menu to select any operating system has vanished.

Can GRUB work together with Windows Vista? Vista has a new bootloader and do not use Boor.ini. I tried this on a Vista machine where the disk is a SATA disk, and it did not work. I was using Ubunto Linux to do the job for me.

Yes it workds fine no problem at all. But if you make changes like formatting a free space in hard drive you may loose control of either operating system. also you will have to learn grub commands to boot any operating system.

When FC3 came along, they said you couldn't make a boot floppy anymore because vmlinuz was too big. I've been using mkiso & burning boot CDs (as backup 'cause you never know). But floppys are so much easier. Even the iso using stage2_eltorito + grub was never bigger than 400K, so why couldn't you use a floppy anymore? Finally followed your recipe w/ the floppy and worked first time: xp, suse & centos. Zero problems. This is one of those rare items that you keep handy forever.
Thanks and thanks again!!
lynnevan

hi i have a proble i installed xp and thenfedero core 5.0 i used sometimes but i didnot look at linux since 2 öonth and today when i restart my machine it enters grub i did not remember grub files..and i have alot off importad info..
how can i get rid of this grub thanks

1. Making the floppy EXACTLY per your instructions: grub "setup" command checks for stage1, yes; stage2, yes; fat_stage1_5: no - and then it installs and reports success. Afterward there is still no fat_stage1_5 on the floppy. That's if I unmounted the floppy. If I didn't unmount the floppy before running grub it complains, "Error 31, File is not sector aligned." In either case, booting the floppy gets me the word
GRUB
and then no further action.

I'm using Foresight Linux, a distant derivative of Red Hat.

2. So I tried using the grub that is already installed on my Foresight partition, just to try stuff out.
> rootnoverify (hd0,0) // that's my Windows XP partition
> makeactive
> chainloader +1
> boot
NTLDR menu shows up, I pick main Windows. Boot process gets quite far along. Then just after the keyboard lights flash and a mouse cursor would normaly appear, I get a blue terminal screen:
"AUTOCHECK program not found, skipping autocheck"
and then in a moment, on a black screen:
"0x0000021a system fatal error..." and other stuff I can't see because it lasts half a second.
And then a spontaneous reboot.

Anybody seen this one? BTW, this Windows boots fine via Norton's BootMagic; it was to get around BootMagic problems that I was trying to use grub to begin with.

I've loaded win-xp2 on first partition then leave 2 partitions for fat32 then on free space I install fedora core 6 test1 but I loaded grub on first boot sector of /boot partition now my system loads win-xp2 only how can I boot fedora now. and I want to configure my Grub on MBR, so what I have to do now.

dual boot with RH, XP, no problem. boot into grub and it worked. with all the hype in the office about ubuntu, i attempted and failed to tri-boot the machine. RH>Grub, Ubuntu>LILO, anyone try to throw a Debian in the mix?

I'd just like to say thank you very very much for this tutorial. It explained the situation much better than anything else I found online, including GRUB's own paltry documentation. My computer now boots again, and I am happy. Make sure this page never 404s.

Trending Topics

Upcoming Webinar

Getting Started with DevOps - Including New Data on IT Performance from Puppet Labs 2015 State of DevOps Report

August 27, 2015
12:00 PM CDT

DevOps represents a profound change from the way most IT departments have traditionally worked: from siloed teams and high-anxiety releases to everyone collaborating on uneventful and more frequent releases of higher-quality code. It doesn't matter how large or small an organization is, or even whether it's historically slow moving or risk averse — there are ways to adopt DevOps sanely, and get measurable results in just weeks.