Boot with GRUB

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

Using the GRUB command line is cool, but after a few thousand system starts, you will probably get a little tired of entering the same commands at the GRUB prompt and long for something a little more automated. Good news from the GRUB gang: you get a fully configurable menu interface at no extra charge! The GRUB boot menu gives you point-and-shoot boot selection, unattended default boot after a configurable timeout, any number of fallback boots if previous boots fail, toggle between command-line and menu modes, and interactive editing of menu selections and password protection. These features give GRUB an ease of use to match its tremendous functionality.

When GRUB boots, it automatically looks for the /boot/grub/menu.lst file on its boot device (the last three letters are “ELL ess tee” and not “one ess tee”). If the file is found, GRUB automatically enters its menu mode and presents the user with a stunning interface, as shown in Figure 2.

Figure 2. GRUB's Boot Menu Interface

Listing 1 [found at LJ's web site] shows the configuration file responsible for this demonstration menu. As you can see, it is a simple text file typical of many UNIX configuration files, where lines starting with hashes (#) and blank lines are ignored.

The first set of commands sets general configuration variables. The timeout command sets the time in seconds to wait for the user to make a selection before proceeding automatically to the default boot. The default command sets which of the following boot stanzas GRUB should attempt to boot automatically. Boot stanzas are numbered implicitly, starting from zero, according to their order of appearance in the configuration file. This order is also how they will be listed in the menu.

The fallback command specifies which of the boot stanzas to load if the default should fail. It is possible to set more than one fallback, as is shown in the example.

The color command lets you breathe a bit of life into the text-mode menu screen. The syntax for the color command is

color  foreground/background  [ hilite-fg/hilite-bg ]

where each of the foreground/background colors is specified with a name from the set of black, blue, green, cyan, red, magenta, brown and light-gray; dark-gray, light-blue, light-green, light-cyan, light-cyan, light-red, light-magenta, yellow and white. Among these colors, only the first eight are used for the background. The optional highlight color pair, if specified, will be used to show the current menu selection. When not specified, GRUB will use the inverse of the normal colors.

The rest of the configuration file consists of the boot stanzas for our demonstration system. The title command marks the beginning of a new boot stanza, and its argument is the label that will be displayed for its entry in the menu, from the first non-white-space character to the end of the line. The remaining commands in each stanza are identical to those used when working from the GRUB command line. The exception here is that we no longer need to give a boot command; GRUB does this job without asking.

This example configuration gives only a sample of the many flexible uses of the GRUB boot loader. Besides multiple OSes, you can use GRUB to set up menu selections for test kernels, rescue kernels, different kernel options and so on.

All in all, the GRUB configuration file will be very similar to your /etc/lilo.conf. And after working with the GRUB command line and these examples, it should be a simple matter of firing up your favorite text editor and creating a menu configuration file suitable for your own system and preferences. Don't worry if it's not perfect the first time; you will see that you can make changes interactively, and the GRUB command line is always available as a fallback.

Once you've got your configuration file, mount your GRUB floppy again, and copy the file (say it has been saved as mygrub.conf) into the magic location:

cp  mygrub.conf /floppy/boot/grub/menu.lst

Now when you boot with your GRUB floppy—presto!—you will be greeted with a lovely boot menu like the one in Figure 2. If you like, just stare at it for the few seconds it needs to count down from the timeout setting, and then it will automatically boot into your default OS. Or, use the arrow keys to highlight the OS you want to load and press return. Or, type c to go to the now-familiar GRUB command prompt. From the command prompt, press ESC to go back to the boot menu again.

It is also possible to edit the entries displayed in the menu. Typing e will open a simple vi-like editor interface for the highlighted entry. This allows you to adjust or add any settings to the configuration before booting. Any changes made here will then remain in effect for the duration of the GRUB session. To make permanent changes, you will later need to edit the configuration file on the boot disk, saving the changes with your text editor.

Play with your GRUB floppy configuration until you have it set up the way you like. After just a few system boots, you'll be slinging through GRUB like hashbrowns in a diner.

______________________

Comments

Comment viewing options

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

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.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix