Boot with GRUB

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

By this time you may be thinking, “Okay, GRUB has got it goin' on. But do I have to keep booting from this lame floppy all the time?” Of course not. Booting from floppy is for weenies.

The operation for installing GRUB on the master boot record of your hard disk is similar to the creation of a GRUB floppy. The one difference is that our floppy has all the resources GRUB needs in one place. That is, the boot image, support and configuration files are all on the floppy device MBR and /boot/grub/ directory. In a hard disk setup, you can choose where you want these resources to be.

For example, you could set up a /boot/grub directory on the first partition of your first hard disk and copy all GRUB's files into it as we did in our floppy setup. In our demonstration system, this would be the Win98 partition, and you may choose to do it that way if you want. But you can also set up the /boot/grub directory up in any device/partition on your machine with a filesystem supported by GRUB. In practice it is usually best to install this support directory in your most frequently used and/or most stable partition; that is, one that you aren't reinstalling all the time.

For this example, we will use the Slackware partition since this stays pretty stable, and I tend to do more tracking and installations in the Debian system. Once this decision is made, everything else is simple. First, boot into Slackware, create the /boot/grub directory and copy GRUB's files into it (these are all the files that the GRUB build installed in the /usr/local/share/grub/i386-pc directory). Make sure to put your handcrafted menu.lst configuration file in here, too.

Next, start GRUB, either with the grub executable you built in Linux or by rebooting with the GRUB floppy. If GRUB starts in menu mode, press c to go to command-line mode. Enter the following commands at the grub prompt:

grub> root (hd0,1)
grub> setup (hd0)
grub> quit

You're done. Your system is now fully GRUB'd, installed in the MBR of your hard disk. Type reboot as root (or take the floppy out and jab the keyboard with the old three-prong) and watch just how fast GRUB comes up now!

A few words of explanation about these installation commands. The first, root (hd0,1), tells GRUB to mount this device, in this case the partition with the Slackware installation. All files will now be relative to this device, so the GRUB installer will know to look for its support files in the /boot/grub directory we created in the Slackware partition.

The second command, setup (hd0), is a simplified front end to GRUB's install command. Note in particular that we specify the device as (hd0) and not (hd0,0). Device (hd0) results in GRUB's installation to the master boot record, which is what we want. If we had instead used (hd0,0), GRUB would be installed to the boot sector of the first partition, rather than the MBR. The difference is crucial; your technical writer makes mistakes like this so you don't have to. While each partition can have a boot sector, your hard disk will have only one master boot record the BIOS loads every time you start your machine. Unless you are doing some kind of funky boot-chaining, like using LILO to boot GRUB, you will usually want to install GRUB in the master boot record.

When GRUB installs itself on a device, it first copies a small piece of itself to the MBR, which it calls stage1. Then it follows stage1 with just enough information about where to find the rest of GRUB. In our example, GRUB will put stage1 in the MBR, followed by a blocklist that points to the Slackware partition. GRUB will then find the rest of what it needs (its stage2 files) in the /boot/grub directory.

To check this setup, just edit the menu configuration file in Slackware's /boot/grub/menu.lst at any time. Any changes will be reflected in the next boot.

Error Recovery

If you should foul up the hard disk installation somehow or want to uninstall GRUB from your system, here's what you need to know.

First, if you ever want to clean your MBR from whatever is installed there, the canonical method is to use the fdisk program from an MS-DOS boot floppy:


Of course, this isn't necessary if you just want to go back to LILO as your system's boot manager. In that case, simply make sure your /etc/lilo.conf file has a line that reads boot=/dev/hda. Then, when the rest of the lilo.conf file is the way you want, just rerun LILO. This will put LILO back on the MBR of your system.

If you install GRUB in the boot sector of a partition, instead of the MBR (such as specifying setup (hd0,0) instead of setup (hd0)), you may need to reinstall that OS's boot loader. In the case of DOS/Windows, this means running the sys command from your DOS/Windows boot floppy: A:> SYS C:.

If, this is a Linux partition, it is again effective to rerun LILO, where /etc/lilo.conf has a line in the boot stanza that reads root=/dev/hda1.

In general, most OSes will have a way to reinstall their partition's boot sector without doing a full reinstallation from scratch. (For FreeBSD, see boot0cfg(8); for OpenBSD, see installboot(8).)

In practice, especially if you followed through on the GRUB floppy examples, you should find that GRUB itself is one of the best rescue and system recovery tools in your toolkit. For example, if you have ever made a screwup in your lilo.conf file, you know you can be in for some major pain if your system won't boot. With GRUB, you always have a miniature, self-contained operating system that can recognize and mount different filesystems, find files, locate kernels and boot them, bringing your system back to life so you can work on it. At times like these, GRUB can save your bacon.



Comment viewing options

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


PrefabrikYapi's picture

very useful article. thanks for sharing your experiences with us.


Anonymous's picture

I need some help for menu.lst file.
I have deleted menu.lst file by mistake. Please let me know how can I restart my computer.

you can get a puppy linux

Todong Ma's picture

you can get a puppy linux live-cd,then use the grub bootloader config tool(in system tools) to reinstall the grub.

Solaris 10 changed something on my Dell Studio Hybrid 140G's HD

Noel Ohashi's picture

I want to use Win and Solaris 9. But since I installed Solaris 10, I no longer can reinstall WIN95/ Xp or Vista. I get this Windows blue Screen of Death everytime it begins the installation process. Should I use KILL DISK to solve this issue?


123's picture

What is the command line to install wireshark into linux puppy ? i use to open linux puppy via virtual machine. anyone can help?


abdujappar's picture

after installing windows7 i can not find the ubuntu linux.i already installed easyBCD1.7.2.NOW there is GRUB command window,how can i direct to the linux system?

How to Boot Fedora 13 disc?

Rishi's picture

i had a fedora 13 x86_64 disc which was burned from iso i powered my system with this disc but system doesn't booting from the disc now i havw to install fedora how can my problem solve?

Windows 7 and Fedora boot problem

metafizik's picture

I am trying to dual boot Fedora and Windows 7. All I know is that Fedora boots from /dev/sdc1 and Windows 7 should be booting from what is /dev/sdb1. I am not sure what I need to put in grub.conf. I am not sure how the /dev/sdb1 corresponds to hd0, etc. Here is what I have: Can someone please help? Thank you, metafizik

title Fedora (
root (hd0,0)
kernel /vmlinuz- ro root=/dev/mapper/vg_mfgmjml
nx-lv_root rd_LVM_LV=vg_mfgmjmlnx/lv_root rd_LVM_LV=vg_mfgmjmlnx/lv_swap rd_NO_L
UKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhg
b quiet
initrd /initramfs-
title Windows7
rootnoverify (sdb1,2)
chainloader +1

Re: Windows 7 and Fedora Boot Problem

ptrinder64's picture

I think you need to change the 'rootnoveryify' statement to something like 'rootnoverify (hd1,0)' assuming that the Windows partition is on a separate hard disk and is on the first partition of that hard disk. If not, let me know the partition structure and I'll try to help with my limited knowledge!

Grub dual boot

Anonymous's picture

Hi guys

I'm not sure this is the right websire for my problem but i'll try anything now.

I have a laptop with Windows XP. I partitioned the drive and installed opensolaris on the second partition. No wheneveri turn on the laptop, Grub opens and only gives me the option for Solaris and not wiondows. I haven't been able to boot to Windows since. I've seen alot about editing the command lines for Grub but i'm new to this.

Does anyone have any idea's on how to solve this? i feel like it's not such a big thing but it's beating me right now.

Big thanks

ı think...

Anonymous's picture

I think The linux is a wonderful programme ;)eglen

Yea I'm having the hardest

AndyMan's picture

Yea I'm having the hardest time getting this to work. I'm not the most tech savy person, but I can follow instructions pretty well. I need a IT next to me to solve this equation. I've had an easier time creating a good tax resolution compared to making this run properly. It looks pretty awesome, and I'd love to make it work on my laptop. Basically I'm just asking for a dummy explanation. It's just not sinking in.


Beauty's picture


i have an Acer Travelmate 5520 laptop, which i have two OS
running on it
2.Ubuntu (Linux)

Both where working fine until now, all i did was to switch my laptop off
and now when im trying to switch it back ON it does not load
the menu or anything. it just stuck at GRUB_ with blincking
cursor, it does not allow me to type or do anything.

I dont want to format the computer as i will loose data, is
there anything i can do to recover from this nightmare???

please help me As Soon As Possible as I have important documents
saved in there

Your help will be highly appreciated.
i can be contacted on
Thank You.

please help... im still

Beauty's picture

please help...
im still struggling with this error

Stuck in Grub

Merlin_vi's picture

Where are you since your last post? Have you resolved this issue or do still need assistance?

Setting up a dual O/S system

Marlowe's picture

I want to run a dual boot system, with Windows on one hard drive and Ubuntu on the other. I had some major hassles when I tried to do this before unaided, not understanding about needing a suitable bootloader. Now, I dare not open the Ubuntu disk again because it took me ages to sort the mess out last time (then, foolishly I got help from a computer shop...) Eventually I had to reinstall Windows XP because I need my computer running. I want to use Linux but am not (yet) technically sophisticated. Can someone please give me some simple instructions how to set up a dual-boot system (2 separate hard drives on 1 computer), so I can get started. I tried contacting a local Linux users group but after 15 emails and no reply I gave up. I also need to know which mobile broadband modems support Linux.



Dual boot

DBeattie's picture

Marlowe, if you put the Ubuntu disk into your CDROM when windows is running it does an autoplay and (at least in Vista) asks if you want to install Ubuntu under windows. The nice thing about this is that you get the dual boot option, yet it is installed under windows (which means you can remove it in like manner). Alternatively, if you boot from the CDROM that has Ubuntu you can either boot from the CDROM and run Ubuntu that way (of course, nothing will be saved and it isn't very useful) or you can perform the install. Performing the install should automatically create a dual boot system, as Ubuntu will install grub with a menu allowing you to choose XP or Ubuntu. If you have problems you can perform searches on grub or lilo. It might be a good idea to research grub and lilo before performing the install to get a good idea of what should happen. I am old hate when it comes to Solaris on SPARC machines, but have only dabbled with Linux on my own. I have successfully changed the boot menu default in the past using grub by following web page instructions (unfortunately the manual pages under linux are a bit difficult to parse, as they only give brief descriptions of options).

how to hide file in rhel5

autonoumos's picture

can i hide folfer and file linux
if yes
which command are used to hide files

name or rename the file or

nilotpal sarkar's picture

name or rename the file or directory wid . As prefix. Eg. Mkdir .redhat

Windows not installing even after editing grub

dhiru's picture

I have fedora12 (on (hd0,4))and windows 7(on (hd0,3)) . I edited grub for windows booting like this:
rootnoverify (hd0,3)
chainloader +1
boot (hd0,3)

But when I select the windows 7 option ,it display "GRUB" (without ">") in a new blank screen ,and nothing works except ctrl+alt+del ; plz help me ,otherwise I will have to format windows7

Is it dead?

Anonymous's picture

upgraded from xp to vista, and dumb me listened to a computer bud to activate free. Well, when the activator restated my module it put me into this grub thing I understand nothing about and don't know what to do. If it requires reformating my C: how can I when I can't access the partition?

Is It Dead??

Anonymous's picture

People still use XP?

Had the same problem...

ericdeko411's picture

I had the same thing happen to me once when I installed Ubuntu on my laptop. I had Vista on it but after the whole GRUB mess I just quit and reinstalled everything.

Eric Deko

Further info...

Anonymous's picture

I am actively searching for a solution nothing has hork. Says must load kernel, but how? root (0,0) gets a "cannot mount selected partition, and not option for windows. My module is an old dell but was in fair order til I let someone else mess with it.

Getting rid of GRUB

Anonymous's picture

GRUB is now in your MBR (Master Boot Record)... In XP when I was tinkering with Linux and no longer wanted it (or GRUB) on my hard drive I just deleted the MBR. Go to a command prompt and just type (without the quotes) "del mbr" then press Enter and reboot. Done! =0) It will restore to a previous backed up version of your MBR and boot Windows as normal.

No go there

Anonymous's picture

I tried and it said "unrecognized cammand"
It's GRUB4DOS 0.4.2 (2007-01-07)
Any other ideas? Thanks.

menu.lst on ext hd

Anonymous's picture

hi, well my hp laptop was running on vista and i installed ubuntu on my ext hd. The problem is i cant boot without plugging in my hd cause i guess the menu.lst is in the linux partition of my ext. hd. It shows a device not found error. Is there any way to relocate the menu.lst file to some where in my windows partition (hp gives only one) and make grub look for it there.

cannot boot packard bell laptop after installing ultimate ubunto

Anonymous's picture

cannot boot packard bell laptop after installing ultimate ubuntu on an external usb 500gig hard drive. if i boot with the usb drive pluged in it (grub i think) gives me the option to boot ubunto on the usb drive or windows on the internal hard drive. if i remove the usb drive and boot the laptop without it, it says that no hard drive is recognised. has grub alterd the MBR on the internal drive. can any one help . thanks john

i have now got my laptop

Anonymous's picture

i have now got my laptop running again by rebuilding the mbr on the laptop hardrive. still to get the ultimate ubuntu running on the external hardrive though

After a coldboot I get grub. How to get my Linux system restored

Anonymous's picture

I am using FEDORA 10 as my OS. It hung so I did a cold boot and after that I find that I get "GRUB>". How am I to recover and restore my OS? I would appreciate all help.
Thanks in advance


Anonymous's picture

i am also facing the same problem. did u get any solution.
let me know plz

thanks in advance


Beauty's picture


im still stragling to get it.
beacause im having the same problem

please tell if you got any help

thanks in advance

Dual Booting Windows 7 and Linux

WB7ODYFred's picture

# edit file /boot/grub/menu.lst to have the following similar lines.
# uncomment by deleting the leading pound sign character '#' at the beginning of each line
# examples assume that the First Hard Disk drive has 2 primary partitions
@ /dev/hd0,0 is the first partition containing Windows
# /dev/hd0,1 is the second partition containing Linux
title Windows 95/98/NT/2000
root (hd0,0)
chainloader +1
title Linux
root (hd0,1)
kernel /vmlinuz root=/dev/hda2 ro
# kernel /vmlinuz root=/dev/sda2 ro if newer Linux kernel

Here are some reference webpages you can read about Grub

At the Grub prompt you can issue these commands
grub> root (hd0,1)
grub> find /boot/grub/stage1

grub> root (hd0,1)
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 19 sectors are embedded.
Running "install /boot/grub/stage1 (hd1) (hd1)1+19 p (hd1,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded

grub> Quit

Alternatively You can use a LiveLinux CD to boot your computer from CDROM
and rescue your existing Windows and Linux installations.

From a friends computer download the .ISO file and burn image to disk
to create a LiveCD bootable Puppy Linux CD.
You can use Grub from running PuppyLinux from CDROM to create file /boot/grub/menu.lst
and then run grub to install the Grub Boot Loader to your MBR of your first hard disk drive.
ie the Master Drive connected at the end of the Primary drive 40 pin cable.

You can use a USB Flash disk to boot your computer in place of a CDROM.
Use the Windows program from to install puppylinux
to a USB Flash Disk Drive. Then edit your BIOS boot order or select Boot from USB Flash Drive first.

I hope the above note and the above links help you recover your Windows and Linux installation.
Please reply here with any corrections, further questions or updates. I am not perfect.
Respectfully, Fred L. Finster WB7ODY


Anonymous's picture

Lilo works just fine. Slackware works just fine. Only thing I had to do was add

root = "UUID=a8a7b440-374f-4cbc-ab87-504c68ef0e335"

for Fedora 13 because it does not understand /dev/sda8. As far as I am concerned Ubuntu Fedora etc. on their way toward Microsoft friendliness are just becoming toys, and I treat them as such.

linux boot problem when i installed windows after linux

Anonymous's picture

i have two operating system(windows xp and linux el4.5). at first i installed linux. next i attached a sata hard disk and installed xp. i installed grub in rescue mode but i can't choose any one of the os from the grub. if chang the first boot device from bios then we can boot each os individually. but without setting of bios i can't.

my two hard disk had been detected as sda and sdb.

boot into linux, then go to

Anonymous's picture

boot into linux, then go to /etc/fstab and edit it. change your drive letters to corrispond to the propper linux boot partition and the swap partition.

Need Help

Anonymous's picture

I am new to linux. I have installed Ubuntu 8 linux, for few weak it was working fine. but today it is showing Grub> I wount able to Boot. I have some important data. how can i load linux...

in my system too Grub went south

Anonymous's picture

In my system also - 2 250G hd - Grub suddenly started to acting up during the boot. I used Puppy Linux Live CD to recover data - it took quite all day long. I went back to the evil empire, because that kind of bug in Linux usually take a year or two to be solved, see the hard drive load problem with the laptops, till now the user have to use the ugly solution to save the hd...

grub rescue disk

Anonymous's picture

How do you make a grub rescue disk when you don't have a floppy drive?

Regarding Grub boot

Anonymous's picture

If you do not install grub on the master boot record of the hard disk, how can you boot Linux?

windows not working after installing redhat on winxp

Anonymous's picture

i have installed Redhat linux on window xp machine. After the installation linux is working with no problem. When i restart my system it showed a menu to choose an operating system. I pressed window xp. But window is not working.

Please help me to solve this problem.


Installing multiple Os on one laptop.. I am stuck--HELP!

princekoj's picture

Is there a way to install multiple OSes on one computer using Grub 2? I tried adding PCLinuxOS 2009 after Windows Vista and Ubuntu 9.10 but it just gives me errors and I cannot get into PCLinuxOS. Is there a step by step guide to using Grub 2, which is default on Ubuntu 9.10, to install multiple OSes on a computer?

I do believe in the updating of tolls even such as Grub, however, it should be easier to install multiple OSes as this is an important thing since there are many flavors of Linux. All the walk-throughs tend to use Grub 1 (for want of a better term).

Any ideas?

I want to install Linux Mint, PClinuxOS and I already have Ubuntu 9.10. I also want to be able to swap any of the last two to test other linuxes.


boot into linux edit your

Anonymous's picture

boot into linux edit your menu list file. Make sure you change your drive letters to corrispond to the drive letters of your pclinux install

tiltle pclinuxos
kernel (hd0,0)/location of kernel goes here
initrd (hd0,0)/location of init file goes here

you may have to edit your fstab file under pclinux to make sure it is pointing to the proper drives for boot and swap.

GRUB gripes

Luke Kendall's picture

My main gripe with grub is that unlike lilo, it has no test mode, where you can check that your new menu.lst actually makes sense, and that it's on a filesystem that will be visible to the grub that will boot.

I've screwed up my menu.lst file dozens of times, and then had to struggle with a printed grub manual to run grub interactively to boot the system, or else boot from a live CD (usually easier, frankly). Most of these mini disasters could have been avoided if grub had a method of testing if the menu.lst file is probably going to work. Not all of them were my fault. I remember one fun time when I upgraded to Ubuntu 8.10 to get grub failing with "Error 2" - this was thanks to ext3 changing from 128 bit to 256 bit inodes.

The article is also looking a bit old: many distros now use grub2 instead of grub, and they're not the same.

And info on grub and mirrored raid would be worthwhile. I have / and /alt-slash, both raid (/dev/md1 as / now and /dev/md0 as /alt-slash), for trying out new or alternative distros. This means I have to do this when updating menu.lst:

root (hd0,5)
setup (hd0)
root (hd1,5)
setup (hd1)
root (hd0,6)
setup (hd0)
root (hd1,6)
setup (hd1)

(At least, I think I have to do this.) Not exactly intuitive, is it?


prajulp's picture

i have an iso image of linuxmint and i dont have any extra cd to burn it.
How can i use GRUB to boot using the iso image just like we do using a LIVE CD

u need a software for

Anonymous's picture

u need a software

for mounting a iso image u need a software power-iso from which u can boot the image diectly...


prajulp's picture

i want to install grub from live cd and i already have XP installed on the hd0
How will i install grub from live cd so that it recoganize the XP partition also

to install linux by live CD

Anonymous's picture

it can installed linux by live cd but the problem is that with this way is many of the linux features may cant work during linux operation so we have to install linux with the traditional process so can avail us the all full featured linux utilities.

selecting EISA configuration partition

Anonymous's picture

I am having IBM thinkpad R52. It is having an EISA configuration partition with IBM_SERVICE name, which can be access by pressing ACCESS IBM button in startup. But its not working. Partition is there it is not deleted.

I want to use restore factory format option from rescue and recovery partition.

Is it possible to use grub to access that partition and how?

Using command prompt to hide important files in an image file

elizas's picture

The sizes of image file increase accordingly. When you double click the image it displays as a normal image. To retrieve the zipped file just right click on the particular image and open it with WinZip/WinRAR, and the archived files will be visible now.You can also change the extension of the image file to .zip so that the hidden files can be accessed simply by double clicking on it.

Any suggestions are welcomed.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot