The Wayback Machine - https://web.archive.org/web/20101202043606/http://www.linuxjournal.com/article/4622

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

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 www.gnu.org/software/grub/grub.html) and downloaded the source distribution into a suitable working directory, continue with:

tar -xzvf grub-0.5.96.1.tar.gz
cd grub-0.5.96.1
./configure
make
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.

______________________

Comments

Prefabrik

PrefabrikYapi's picture

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

menu.lst

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?

help

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?

hello

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

#boot=/dev/sdc
default=0
timeout=30
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.33.3-85.fc13.i686.PAE)
root (hd0,0)
kernel /vmlinuz-2.6.33.3-85.fc13.i686.PAE 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-2.6.33.3-85.fc13.i686.PAE.img
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.

GRUB ERROR

Beauty's picture

Hi

i have an Acer Travelmate 5520 laptop, which i have two OS
running on it
1.WindowsXP
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
beautie7@yahoo.com
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

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

Regards

Marlowe

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
how?
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

Hi!
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
James
jayant.james@gmail.com

hi

Anonymous's picture

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

thanks in advance

hi

Beauty's picture

Hi

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)
makeactive
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
http://www.uruk.org/orig-grub/install.html

http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_3.html
http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_4.html

http://www.gnu.org/software/grub/manual/html_node/Installing-GRUB-using-...
http://www.gnu.org/software/grub/manual/html_node/Installation.html#Inst...
http://www.gnu.org/software/grub/manual/html_node/Invoking-grub_002dinst...
http://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable...

http://www.linuxquestions.org/linux/answers/Applications_GUI_Multimedia/...

http://josephhall.org/grub_install_hda1.html


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

grub>
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.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+19 p (hd1,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

grub> Quit

Alternatively You can use a LiveLinux CD to boot your computer from CDROM
and rescue your existing Windows and Linux installations.
http://www.linuxlivecd.com
http://www.puppylinux.org/news
http://distro.ibiblio.org/pub/linux/distributions/puppylinux/puppy-5.1/l...
http://puppylinux.org/main/index.php?file=Overview%20and%20Getting%20Sta...

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 http://www.linuxlivecd.com 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

grub

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

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

by
M.Sivakumar

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.

Thanks.

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?

BOOOT USING ISO image

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

INSTALL GRUB FROM LIVE CD

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.

thanks
Any suggestions are welcomed.