Little Girl's Mostly Linux Blog

GRUBTips

GRUB Tips

This page was last updated on July 18, 2009.

Table of Contents


Introduction

This document gives step-by-step instructions on how to do some common things with GRUB in Kubuntu or Ubuntu. It is by no means intended to be an all-inclusive manual. Its intent is to be a reference document containing various tasks you might wish to use GRUB for so you can find them all in one place.


How To Use This Document

  • Make sure you meet the requirements in the Requirements section of this document.
  • Refer to the Further Information section for links to some pages on the internet that provide more detailed information than is available here.
  • Refer to the Questions And Answers section for the answers to questions that commonly come up.
  • Refer to the Troubleshooting section if you’ve followed the instructions on this page and something is not working.


Requirements

  • A computer running Ubuntu or Kubuntu (both of which come with GRUB by default).
  • GRUB, and an understanding of GRUB. See the Further Information and Questions and Answers sections of this document.
  • An understanding of how sudo, gksudo and kdesudo work. See the Further Information section of this document.


Things You Can Do With GRUB


Back up GRUB

Back up your /boot/grub/menu.lst file any time you are going to be altering any of its settings!

  1. This command will make a copy of the file, adding the current date and time to the backed up file’s name. Open a terminal window and type:
  2. sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.`date +%b-%d-%Y~%T`


Boot into recovery mode

WARNING: This method gives you root access to the computer without requiring a log-in.

  1. When you boot the machine, it will do one of two things:
    • If you are dual-booting, it will pause automatically at the GRUB menu for a few seconds before booting into the default operating system.
    • If you’re not dual booting, it will pause automatically at a GRUB prompt for a few seconds before booting into the operating system. While the GRUB prompt is visible, you can press the ‘Esc‘ key to bring up the GRUB menu.
  2. If you select recovery mode, you’ll boot into single-user mode in a terminal.
  3. Once inside the terminal you can troubleshoot your computer.


Change default boot order

You can change the default boot order by choosing the default entry that GRUB loads when you boot your computer.

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, read the file from the top down. Count each line that begins with “title” (ignore everything else!), stopping the count at the entry you wish to have loading by default. In this example, I’ve removed everything except for the “title” lines so you can see how it’s being done. Your title lines might look something like this:
  4. title Ubuntu, kernel 2.6.20-14-generic
    title Ubuntu, kernel 2.6.20-14-generic (recovery mode)
    title Ubuntu, memtest86+
    title Other operating systems:
    title Microsoft Windows XP Home
    
  5. GRUB starts the count with zero, so begin counting at zero and work your way down to the title line that has the name of the entry you wish to load by default. If, for instance, you want XP to load by default, you must count all the title lines, finishing the count at the XP line. Since we began the count with zero, XP is the 4th entry, as seen here where I used indicators showing how the lines were counted:
  6. title Ubuntu, kernel 2.6.20-14-generic                 <--- 0
    title Ubuntu, kernel 2.6.20-14-generic (recovery mode) <--- 1
    title Ubuntu, memtest86+                               <--- 2
    title Other operating systems:                         <--- 3
    title Microsoft Windows XP Home                        <--- 4
    
  7. Now that you know the number to use for your default entry, do a search in the file for a line that begins with “default“. The line will look something like this:
  8.   default		0
    
  9. Change the number to the number for your chosen default entry. From our example above, XP was the 4th title entry, so the line would be changed to this:
  10.   default		4
    
  11. Save and exit the file.
  12. Reboot the computer.

NOTE: Whenever the kernel is updated, the new kernel will be added to the file as an entry in GRUB. This will change the numbering of the entries and you’ll need to follow these instructions again to ensure that the proper entry is selected by default.


Change GRUB time-out

To change the GRUB time-out from the default setting of 3 seconds to another value, follow these instructions. In this example, we are changing the timeout to 10 seconds:

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, find the timeout line, which will look something like this:
  4.   timeout		3
    
  5. Change the timeout line to this:
  6.   timeout		10
    
  7. Save and exit the file.
  8. Let GRUB know you made changes:
  9. sudo update-grub
  10. The next time you boot your machine, GRUB will time-out for the length of time you specified.


Display GRUB menu in color

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, find the Pretty colors entry which will look like this:
  4. # Pretty colours
    #color cyan/blue white/blue
    
  5. Delete the hash mark in front of the second line so the Pretty colors entry now looks like this:
  6. # Pretty colours
    color cyan/blue white/blue
    
  7. Save and exit the file.
  8. Let GRUB know you made changes:
  9. sudo update-grub
  10. The next time you boot your machine, GRUB will display in color.


Display GRUB menu in custom colors

If the default color scheme in Pretty colors isn’t quite your style, the colors can be customized to please just about anyone.

Choose custom colors to replace the defaults

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, find the Pretty colors entry which, since you’ve already enabled it, will look like this:
  4. # Pretty colours
    color cyan/blue white/blue
    
  5. The syntax for this command is:
  6. color foreground/background foreground/background

    There are two sets of “foreground/background” in the command. The first set is the foreground and background color of normal menu entries and the second set is the foreground and background color of highlighted entries.

  7. Choose the colors you’d rather have the GRUB menu displayed in by using the GRUB color chart below. Note that you can make the foreground color blink by selecting colors from the blinking column of the chart.
  8. Replace “cyan/blue” and “white/blue” (the default colors) with the colors you picked out. An example of customized colors is:
  9. # Pretty colours
    color light-red/black blink-yellow/brown
    
  10. Save and exit the file.
  11. Let GRUB know you made changes:
  12. sudo update-grub
  13. The next time you boot your machine, GRUB will display in the custom colors you chose.

Choose custom colors for specific menu entries

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, find any “title” line you’d like to change. For example:
  4.   title Linux

    or:

      title Windows XP
  5. Directly beneath the title line you’d like to define custom colors for, add a color line like this example, substituting the colors you like from the GRUB color chart below for “foreground/background” in this example:
  6.   color foreground/background foreground/background
  7. An example of custom colors defined for the Linux menu entry is:
  8.   title Linux
      color light-magenta/cyan blink-white/black
    
  9. Save and exit the file.
  10. Let GRUB know you made changes:
  11. sudo update-grub
  12. The next time you boot your machine, GRUB will display in the custom colors you chose.


GRUB color chart

Foreground colors Blinking foreground colors Background colors
dark-gray blink-dark-gray black
light-blue blink-light-blue blue
light-green blink-light-green green
light-cyan blink-light-cyan cyan
light-red blink-light-red red
light-magenta blink-light-magenta magenta
yellow blink-yellow brown
white blink-white light-gray


Edit GRUB by using a Live Ubuntu or Kubuntu CD

NOTE: Substitute your hard drive partition information for XdYZ in these commands, using hda1 or sda2 or whatever your device’s name is.

  1. Boot with the Ubuntu or Kubuntu Live CD.
  2. Create a mount point by opening a terminal window and typing:
  3. sudo mkdir /media/XdYZ
  4. Mount the partition to that mount point:
  5. sudo mount /dev/XdYZ /media/XdYZ
  6. Back up GRUB:
  7. sudo cp media/XdYZ/boot/grub/menu.lst media/XdYZ/boot/grub/menu.lst.`date +%b-%d-%Y~%T`
  8. Open the /boot/grub/menu.lst file:
    • GNOME users:
    • gksudo gedit media/XdYZ/boot/grub/menu.lst
    • KDE users:
    • kdesudo kate media/XdYZ/boot/grub/menu.lst
  9. In the editor you just opened, make whatever changes you need.
  10. Save and exit the file.
  11. Let GRUB know you made changes:
  12. sudo update-grub
  13. Restart the computer and remove the Live CD.


Edit GRUB graphically

There’s a script available at http://ubuntuforums.org/showthread.php?t=228104 which gives you a GUI to use for editing GRUB.

NOTE: If you use Gutsy Gibbon, please do not use this script until the author removes the notice on that page stating that it’s not safe to use on Gutsy yet.


Edit GRUB with a specialized Live CD

Super Grub Disk is a Live CD available from http://www.supergrubdisk.org/. You can download the .iso file, burn it to a CD and boot the computer with it to edit GRUB.


Restore GRUB by using a Live Ubuntu or Kubuntu CD

If you had GRUB installed, but somehow lost it because the Master Boot Record got erased or overwritten, you can recover from this by using the Ubuntu or Kubuntu Live CD.

  1. Boot with the Ubuntu or Kubuntu Live CD.
  2. Open a terminal window and type:
  3. sudo grub

    This will put you into the GRUB shell where you should have a GRUB prompt like this:

    grub>
  4. Have GRUB search for the device(s) it was previously on:
  5. find /boot/grub/stage1

    NOTE: If this command returns more than one device, select the one you’d like GRUB to be installed on.

  6. Substitute the device GRUB found in step 3 for “hdX,Y” in this command:
  7. root (hdX,Y)
  8. Install GRUB to the Master Boot Record:
  9. setup (hd0)
  10. Exit the GRUB shell:
  11. quit
  12. Restart the computer and remove the Live CD.


Restore GRUB to a specific partition by using a Live Ubuntu or Kubuntu CD

If you had GRUB installed to a specific partition instead of to the Master Boot Record, but somehow lost it because the files got erased or overwritten (or you need to restore GRUB after restoring a ghosted drive), you can recover from this by using the Ubuntu or Kubuntu Live CD.

  1. Boot with the Ubuntu or Kubuntu Live CD.
  2. Open a terminal window and type:
  3. sudo grub

    This will put you into the GRUB shell where you should have a GRUB prompt like this:

    grub>
  4. Have GRUB search for the device(s) it was previously on:
  5. find /boot/grub/stage1

    NOTE: If this command returns more than one device, select the one you’d like GRUB to be installed on.

  6. Substitute the device GRUB found in step 3 for “hdX,Y” in this next command:
  7. root (hdX,Y)
  8. Substitute the device GRUB found in step 3 for “hdX,Y” in this next command:
  9. setup (hdX,Y)
  10. Exit the GRUB shell:
  11. quit
  12. Restart the computer and remove the Live CD.


Text boot with splash screen

Choose one of these methods if you’d like a text boot accompanying the splash screen:

Temporary method 1

  1. When the Ubuntu or Kubuntu logo is on the screen, press all of these keys at the same time:
  2. Ctrl + Alt + left arrow

    Note: I haven’t tested this method (I keep forgetting to), so try it at your own risk.

Temporary method 2

  1. When the GRUB menu appears, highlight the Ubuntu Linux entry.
  2. Press the ‘e‘ key.
  3. Go to the kernel line that looks something like this:
  4.   kernel		/vmlinuz-2.6.22-14-generic root=UUID=XXXXXXXXXX ro quiet splash
  5. Press the ‘e‘ key again.
  6. Remove the word ‘quiet‘ from that line.
  7. Press the ‘Enter‘ key to accept the change.
  8. Press the ‘b‘ key to boot the machine.


Text boot no splash screen

Choose one of these methods if you’d like a full text boot with no splash screen:

Temporary method 1

  1. When the Ubuntu or Kubuntu logo is on the screen, press both of these keys at the same time:
  2. Alt + left arrow

Temporary method 2

  1. When the GRUB menu appears, highlight the Ubuntu Linux entry.
  2. Press the ‘e‘ key.
  3. Go to the kernel line that looks something like this:
  4.   kernel		/vmlinuz-2.6.22-14-generic root=UUID=XXXXXXXXXX ro quiet splash
    
  5. Press the ‘e‘ key again.
  6. Remove the ‘quiet’ and ‘splash’ options.
  7. Press the ‘Enter‘ key to accept the changes.
  8. Press the ‘b‘ key to boot the machine.

Permanent method 1

This will need to be repeated whenever you get a new kernel.

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, find the kernel line which will look something like this:
  4.   kernel		/vmlinuz-2.6.22-14-generic root=UUID=XXXXXXXXXX ro quiet splash
    
  5. Delete the words ‘quiet‘ and ‘splash‘ and replace them with the word ‘verbose‘.
  6. Save and exit the file.
  7. Let GRUB know you made changes:
  8. sudo update-grub
  9. The next time you boot your machine, you’ll have a full text boot in that kernel.

Permanent method 2

This will work even when you get a new kernel.

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, find this line:
  4.   # defoptions=quiet splash
    
  5. Remove the words ‘quiet‘ and ‘splash‘ from the line.
  6. Advanced: If you’d like high resolution text, you can add ‘vga=791‘ to the line.
  7. Save and exit the file.
  8. Let GRUB know you made changes:
  9. sudo update-grub
  10. The next time you boot your machine, you’ll have a full text boot.


Unhide the GRUB menu

If you only have one operating system on your computer, you need to press the Esc key to get into the GRUB menu on boot. If you’d rather have the menu displayed for a few seconds during each boot, this setting can be changed.

  1. Back up GRUB.
  2. Open the /boot/grub/menu.lst file by opening a terminal window and typing one of these commands:
    • GNOME users:
    • gksudo gedit /boot/grub/menu.lst
    • KDE users:
    • kdesudo kate /boot/grub/menu.lst
  3. In the editor you just opened, find the line that says “hiddenmenu” as in this example:
  4.   ## hiddenmenu
      # Hides the menu by default (press ESC to see the menu)
      hiddenmenu
    
  5. Place a hash mark in front of that line, as in this example:
  6.   ## hiddenmenu
      # Hides the menu by default (press ESC to see the menu)
      #hiddenmenu
    
  7. Save and exit the file.
  8. Let GRUB know you made changes:
  9. sudo update-grub
  10. The next time you boot your machine, the GRUB menu will be displayed automatically.


Appendix

Further Information


Questions and Answers

What is GRUB?
GRUB stands for GRand Unified Bootloader. A boot loader is the first program that runs when your computer starts, determining which operating system gets loaded.
I have a question that hasn’t been asked here. How do I ask it?
If you use the contact address at the top of this document, you will receive a reply via email and your question may be added to this section.


Troubleshooting

  • Make sure that you meet the requirements in the Requirements section.
  • If you need more interactive help, see my GettingHelp page.



Obligatory Happy Ending

And they all lived happily ever after. The end.

2 Comments »

  1. That’s probaby the best guide for Grub. I like to read a similar one for Grub 2.

    Comment by Ikem — September 4, 2012 @ 6:16 am

    • Thanks! I’ll see if I can put one together, although Grub 2 and I haven’t been formally introduced yet since I haven’t had any reason to do any Grub work lately (knock on wood). :)

      Comment by mostlylinux — June 2, 2013 @ 8:39 am


RSS feed for comments on this post. TrackBack URI

Comment:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: