Boot with GRUB

Especially useful for multiboot, partitioned systems, GRUB offers flexibility and convenience for startup.

GRUB: it's neither larva, fast food nor the loveliest of acronyms in the GNU herd of free software. Rather, GRUB is the GNU GRand Unified Bootloader. And, it is truly the greatest loader for booting Linux and practically any other OS—open source or otherwise—you may have scattered on your platters.

GRUB is independent of any particular operating system and may be thought of as a tiny, function-specific OS. The purpose of the GRUB kernel is to recognize filesystems and load boot images, and it provides both menu-driven and command-line interfaces to perform these functions. The command-line interface in particular is quite flexible and powerful, with command history and completion features familiar to users of the bash shell.

GRUB is in its element with the multiboot, multidisk systems typical of Linux and open-source adventurers who may simultaneously test or track several Linux distributions, the BSDs, GNU/Hurd, BeOS and perhaps that vestigial partition for Mr. Bill. Even if you stick with LILO as your system's primary boot loader, it's smart to keep a GRUB boot floppy handy as the best and fastest way to get your system back if you otherwise cream your master boot record (MBR). If you have done any number of multiboot installations, you know exactly what I'm talking about. Should you need any more reasons for considering GRUB, check out the sidebar, “Why GRUB”. Let's get started!


Installation of GRUB is a two-step process. The first step is to install or build GRUB in a host OS environment, and for this we will, of course, use Linux. The second step is to install and configure GRUB as the boot loader for your system.

The first step is the usual: download the source archive, untar it, configure and make install. Assuming you have found a source mirror (see and downloaded the source distribution into a suitable working directory, continue with:

tar -xzvf grub-
cd grub-
make install

This should create the executables: grub, grub-install and mbchk; install support files in /usr/local/share/grub/i386-pc/, and install the GNU information manual and man pages.

For the second step of installation, we will first build and work with a GRUB boot floppy. This way we can use GRUB to learn about its features while testing various configurations for our particular system. After getting comfortable with the GRUB setup on floppy, we will then install it onto the MBR of the system's first hard disk. Even if you decide not to install GRUB on your hard disk right away, no harm done: you will now have your own GRUB boot floppy available to rescue systems with trashed boot loaders.

Preparing a GRUB floppy

GRUB recognizes a number of different filesytem types, including Linux ext2fs, Reiser, MINIX, BSD's ffs, as well as FAT, so it is possible to make a GRUB boot floppy with any of these filesystems. We will stick to FAT for this example, however, because it is the lowest common denominator, and most OSes have tools for mounting and reading/writing files on FAT floppies. That way, we will always be able to get to its menu configuration file if we need to.

Scrounge around in your junk drawer for some unused floppy (a new one would be even better), and give it a fresh format and FAT filesystem:

fdformat /dev/fd0
mkfs -t msdos /dev/fd0

We are going to put some files on this disk, so go ahead and mount to your usual floppy mount point (here I use /floppy):

mount -t msdos /dev/fd0 /floppy
Now install the directories and files GRUB will need:
mkdir -p /floppy/boot/grub
cp /usr/local/share/grub/i386-pc/stage* /floppy/boot/grub
The floppy can then be unmounted, umount /floppy, but leave it in the drive. The GRUB floppy is prepared and ready for the final installation, which is to install the GRUB boot loader in the MBR of the floppy itself. For that, we will use the grub executable we have built with our Linux installation. Start the executable at the Linux command prompt: grub.

This brings up an emulator of GRUB's command shell environment, which looks like Figure 1. We will discuss the features of this shell in more detail a little further on. For now, enter the following series of commands at the grub prompt:

grub> root (fd0)
grub> setup (fd0)
grub> quit

Figure 1. GRUB in command-line mode. Note the on-line help (here the GRUB emulator is running under Linux in an xterm window).

And that's it! This sequence of commands completes the installation of GRUB on the floppy disk. It is now bootable and will allow us to boot any other OS on our system.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Aky's picture

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

Cannot boot into RHEL5 after reinstalling windows XP SP3

anyl's picture

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.

Linux Grub! NEED HELP!

Anonymous's picture

I NEED HELP!!! I have Linux grub installed and I can't get past the boot up screen! It checks the system and at the end it has this: #_(blinking). What do I do!? Someone help!

blicking bootup screen

J et's picture


I had this problem too, I solved it by going into the BIOS and then making sure that the boot options list that my hard disk is top priority.

Hope this helps.


unable to boot Vista after installing linux

MarcoG's picture


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.

Thank you



mozebyciu's picture

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?

GRUB error

Wasiuizzaman's picture

Hi all

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.

Thanks Russell

Not Good

Mitch Frazier's picture

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:

grub> root (hd0, PRESS-THE-TAB-KEY

This should show you the partitions that you have, something like:

 Partition num: 0, Filesystem type is XXXX, partition type YYYY
 Partition num: 1, Filesystem type is XXXX, partition type YYYY

You should see one whose type is ntfs, that's the Windows partition. Use it's partition number and do:

grub> rootnoverify (hd0,YOUR-WINDOWS-PARTITION-NUMBER)
grub> makeactive
grub> chainloader +1
grub> boot

That will hopefully boot you into Windows.

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

Mitch Frazier is an Associate Editor for Linux Journal.


Anonymous's picture


Fedora 7 grub setup successful

Anonymous's picture

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


File Type Unknown

Anonymous's picture

Hello Sir Mitch,

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.

Need YOur help

You can revert back to me on



Mitch Frazier's picture

Try changing the partition type of the your NTFS partition to the correct type using fdisk or some other tool. You can also try running ntfsfix on the partition.

Mitch Frazier is an Associate Editor for Linux Journal.

Grub Permission

Blackaddar's picture

I installed a dual-boot system on my Dell with Ubuntu Linux and Windows XP. Linux is installed on a second external Hard drive.

I can get into the menu.lst file in the linux test editor, but an
unable to change the file, due to lack of permission.

This is mystifing, since I am the only user and the Administor of the Laptop.

How can I get permission to edit this file?

Any help appreciated.

Michael B. Harris
Linux user #1063


Anonymous's picture

enable root account
sudo passwd root
then login as root
u will get full permission

try sudo

Anonymous's picture

try at the term:
sudo gedit
sudo nano

Edit File

Mitch Frazier's picture

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.

Mitch Frazier is an Associate Editor for Linux Journal.


Anonymous's picture

hey all..can you help me REMOVE grub loader from my system without removing Linux..i want windows to be the default loader or whatever..


Anonymous's picture


Hope this may solve your problem

Aamir Shahzad


AS prefabrik's picture

Great article thanks. Written in 2001 and yet here we are still referring to it. If the author is reading this I would be curious to know how Linux is used in West Africa.

tlamelo, sounds like a GRUB config error - my advice is to burn a copy of "System rescue CD",

It works as a Linux live cd, This has grub on it and will let you fix your GRUB install. Note the "chainloader +1" and "make active" bit in the artcile example for Win98 applies to XP and Vista too.

Booting issue

Raj's picture

Hai every one...
When i startup my linux server it shows that /raj(mount point direcotry) is checking filesystem 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

böcek ilaçlama

böcek ilaçlama's picture

You have just saved my beloved Tux. I am no good on managing boot loader, and often end with screwed up hard disk. :)

Great Article and reply to tlamelo

Imran Chaudhry's picture

Great article thanks. Written in 2001 and yet here we are still referring to it. If the author is reading this I would be curious to know how Linux is used in West Africa.

tlamelo, sounds like a GRUB config error - my advice is to burn a copy of "System rescue CD",

It works as a Linux live cd, This has grub on it and will let you fix your GRUB install. Note the "chainloader +1" and "make active" bit in the artcile example for Win98 applies to XP and Vista too.

booting windows with grub result to this

tlamelo's picture

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

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'
vista loader 2.0.0

fallback 1
find --set-root /bootmgr

error 17: file not found
booting 'windows NT/2000/XP'

fallback 2
find -- set-root /ntldr

error 17: file not found
booting 'Enter Command Line'

boot failed! Press any key to enter command line."

when i press anykey it give me "GRUBDOS 0.4.2 (2007-03-02, memory:639k / 502m, code end: 0x4013c

[minimal BASH-LIKE LINE EDITING IS SUPPORTED. FOR THE FIRST WORD, tab lists possible command completions. anywhere else tab lists the posible completions of a device/filename. ESC at any time exits.]


when i press esc i get windows vista, windows NT/2000/XP AND ENTER COmmand line

this comes in a black screen with some options at the bottom such arrows to highlight, press ENTER to boot the selected OS, 'e' to edit the commands before booting, 'c' for a command -line.

with all this guys what can i do to remove linux and XP which i never succeded to install and remain with only my vista. for the time being nothing works.THANK YOU IN ADVANCE

Reformat that Hard Drive!

Anonymous's picture

Reformat that Hard Drive! Sounds like a mess!

grub bios

sikis's picture

If you're working with Linux distributions, especially the things you need to know grub. How important is bios in windows linux grub is important

Linux vs centos grub

sikis's picture

Thank document in good time grub error because CentOS gold lost my system many times, but the group recognized that this problem is very low...

How to install the grub on xp(1st HD) and Ubuntu(2nd HD)

Joli's picture

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

Hey can any one help me to

Anonymous's picture

Hey can any one help me to make bootable CD for my application in linux having kernel of 10MB and initrd.gz as 95Mb. my email-id is

Thanks in advance

From info grub : $

Anonymous's picture

From info grub :

$ mkdir iso

Make a directory for GRUB:

$ mkdir -p iso/boot/grub

Copy the file `stage2_eltorito':

$ cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub

If desired, make the config file `menu.lst' under `iso/boot/grub'
(*note Configuration::), and copy any files and directories for the
disc to the directory `iso/'.

Finally, make a ISO9660 image file like this:

$ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -o grub.iso iso


Anonymous's picture

My son has been messing around with the computer
When i´m starting it ,the message tells me at first that it´s installing grub and then there´s error 17.
I can´t use the computer ,what´s the solution?

Grub Error 17 Or Something Recovery

Anonymous's picture

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:

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

Well hope i helped...

GRUB on Serial Console

Marian Marinov's picture

First let me say that this is a great article.

However I have commonly seen people who are unable to configure grub for working on serial console and they tend to argue that this is even possible.

Here is a simple way how you can configure GRUB to work on the serial console:

First you need to specify the serial port and the options for this port:

serial --unit=0 --speed=9600

Valid options for serial are:
[--unit=unit] [--port=port] [--speed=speed] [--word=word] [--parity=parity] [--stop=stop] [--device=dev]

Unit is usually 0-3 as com1 trough com4.

Second you have to setup the terminal for this port:
terminal --timeout=3 serial console

Valid options for terminal are:
[--dumb] [--no-echo] [--no-edit] [--timeout=secs] [--lines=lines] [--silent] [console] [serial] [hercules]


Grub boot floppy doesn't work - gets kernel panic

Larry's picture

I use Kubuntu Gutsy with root partition on sata /dev/sda1 and /home on /dev/sda5.
When I issue the boot command at grub prompt, computer locks up after these two lines:

Please append a correct "root=" boot option; here the available partitions
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,3)

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.

Something is missing in my setup - can anyone please help me find it?


You need SATA Driver

Anonymous's picture

You need SATA Driver sata_nv.

Grub Menu Not Coming up

Kunjal's picture

Hi ,

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.

Any help on this is highly appreciated.

Thank You,

How about Windows Vista?

Anonymous's picture

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 works fine.

Kunjal's picture

Hi ,

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.

Thank You,

Great info - Worked first time

lynnevan's picture

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!!

Thank's for the info

Aji Setiabudi's picture

You have just saved my beloved Tux. I am no good on managing boot loader, and often end with screwed up hard disk. :)

xp&fc5 reboot and enter grub

ayhan's picture

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

Can't make the floppy, can't boot XP

Sparklight's picture

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

triple boot with grub

new to linux - ubuntu's picture

Hello, I found this very helpfull, but I need to do one more thing with grub, but how???

first of all I have 3 OS-s (2 of them are win xp and third is Ubuntu 6.06)

*How to hide one xp partition from another with grub?
**Is it possible to do so if I have only one hard disk?

fedora core 6 test1 instal problem

somendra's picture

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.

just do it...

Ravi's picture

by using same CDs of FC6 upgrade that GRUB i.e grand unified boot loader it loads GRUB and ur both OS will works fine....

install on first boot sector of a partition

Pascal Valois's picture

when doing this, you rely on the boot sector of the bootable disk to hop to grub.

in fact, the basic boot sector search for the active partition, and then load the boot sector of it to ensure the OS boot.

in your case, using windows, with the fdisk tool, make your /boot linux partition bootable (active).

then reboot, and it should works


Atiq's picture

I m really thankfull to you ... coz due to this i saved lots of my important data... thanks.

tri-boot with RH, XP, and Ubuntu?

Anonymous's picture

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?

thanks in advance... end up reinstalling RH because Ubuntu screwed my partition already :(

problm in installing GURB

pkg's picture

after installing UBUNTU
it com restarts & it writes "grub is loding please wait..."
and after that it has taken hours but nothing is working after word.
winXP is also not working

reinstall ur grub if nt

Anonymous's picture

reinstall ur grub
if nt able to load windows u must write the code snippet


Anonymous's picture

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.