GNU GRUB (Legacy) is a multiboot bootloader maintained by the GNU Project. It was derived from GRUB, the GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn.
Briefly, the bootloader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.
Currently, GRUB is the de facto standard bootloader of Linux, and is expected to be superseded by GRUB2 in the near future. Upstream refers to "GRUB" (Arch Package) as "GRUB Legacy" and "GRUB2" (Arch package) as "GRUB".
- 1 Installation
- 2 Configuration
- 3 Bootloader installation
- 4 Tips and tricks
- 5 Advanced Debugging
- 6 Troubleshooting
- 7 External resources
The GRUB package is installed by default when you install Arch Linux. If you previously selected not to install this package, you can install now via:
Additionally, GRUB must be installed to the boot sector of a drive or partition to serve as a bootloader. This is covered in the #Bootloader installation section.
The configuration file is located at Template:Filename. Edit this file to suit your needs.
- Template:Codeline -- time to wait (in seconds) before the Template:Codeline operating system is automatically loaded.
- Template:Codeline -- the default boot entry that is chosen when the Template:Codeline has expired.
An example configuration (Template:Filename is on a separate partition):
Finding GRUB's root
GRUB must be told where its files reside on the system, since multiple instances may exist (i.e., in multi-boot environments). GRUB files always reside under Template:Filename, which may be on a dedicated partition.
The following example is for systems with a separate Template:Filename partition:
GRUB will find the file, and output the location of the stage1 file. For example: Template:Command
Dual booting with Windows
If Windows is located on another hard disk, the map command must be used. This will make your Windows install think it is actually on the first drive. Assuming that your Windows partition is on the first partition of the second drive: Template:File
Dual booting with GNU/Linux
This can be done the same way that an Arch Linux install is defined. For example: Template:File
To facilitate system maintenance, the Template:Codeline or Template:Codeline command should be used to boot another Linux distribution that provides an "automagic" GRUB configuration mechanism (e.g. Debian, Ubuntu, openSUSE). This allows the distribution to manage its own Template:Filename and boot options.
- The Template:Codeline command will load another bootloader (rather than a kernel image); useful if another bootloader is installed in a partition's boot sector (GRUB, for example). This allows one to install a "main" instance of GRUB to the MBR and distribution-specific instances of GRUB to each partition boot record (PBR).
- The Template:Codeline command will instruct the currently running GRUB instance to load the specified configuration file. This can be used to load another distribution's Template:Filename without a separate GRUB installation. The caveat of this approach is that other Template:Filename may not be compatible with the installed version of GRUB; some distributions heavily patch their versions of GRUB.
--------------------------------------------- | | | | % | | M | | | B % | | B | (hd0,0) | (hd0,1) | L % (hd0,2) | | R | | | % | | | | | % | --------------------------------------------- | ^ | chainloading | -----------------------------
One can simply include in Template:Filename:
title Other Linux root (hd0,2) chainloader +1
Or, if the bootloader on Template:Codeline is GRUB:
title Other Linux root (hd0,2) configfile /boot/grub/menu.lst
The Template:Codeline command can also be used to load the MBR of a second drive:
title Other drive rootnoverify (hd1) chainloader +1
Dual booting with GNU/Linux (Grub2)
Selecting this entry at boot will load the other distribution's Grub2 menu assuming that the distribution is installed on Template:Filename.
Manual recovery of GRUB libs
The Template:Filename files are expected to be in Template:Filename, which may not be the case if the bootloader was not installed during system installation or if the partition/filesystem was damaged, accidentally deleted, etc.
Manually copy the grub libs like so: Template:Cli
General notes about bootloader installation
GRUB may be installed from a separate medium (e.g. a LiveCD), or directly from a running Arch install. The GRUB bootloader is seldom required to be reinstalled and installation is not necessary when:
- The configuration file is updated.
- The GRUB package is updated.
Installation is necessary when:
- A bootloader is not already installed.
- Another operating system overwrites the a Linux bootloader.
- The bootloader fails for some unknown reason.
Before continuing, a few notes:
- Be sure that your GRUB configuration is correct (Template:Filename) before proceeding. Refer to #Finding GRUB's root to ensure your devices are defined correctly.
- GRUB must be installed on the MBR (first sector of the hard disk), or the first partition of the first storage device to be recognized by most BIOS's. To allow individual distributions the ability to manage their own GRUB menus, multiple instances of GRUB can be used, see #chainloader and configfile.
- Installing the GRUB bootloader may need to be done from within a Template:Codelineed environment (i.e. from installed environment via a separate medium) for cases like RAID configurations or if you forgot/broke your GRUB installation. You will need to Change Root from a LiveCD or another Linux installation to do so.
First, enter the GRUB shell:
Installing to the MBR
The following example installs GRUB to the MBR of the first drive:
Installing to a partition
The following example installs GRUB to the first partition of the first drive:
Alternate method (grub-install)
Use the Template:Codeline command followed by the location to install the bootloader. For example to install the GRUB bootloader to the MBR of the first drive:
GRUB will indicate whether it successfully installs. If it does not, you will have to use the GRUB shell method.
Tips and tricks
Additional configuration notes.
One can use the resolution given in the Template:Filename, but you might want to use your LCD wide-screen at its full native resolution. Here is what you can do to achieve this:
On Wikipedia, there is a list of extended framebuffer resolutions (i.e. beyond the ones in the VBE standard). But, for example, the one I want to use for 1440x900 (Template:Codeline) does not work. This is because the graphic card manufacturers are free to choose any number they wish, as this is not part of the VBE 3 standard. This is why these codes change from one card to the other (possibly even for the same manufacturer).
So instead of using that table, you can use one of the tools mentioned below to get the correct code:
GRUB recognized value
This is an easy way to find the resolution code using only GRUB itself.
On the kernel line, specify that the kernel should ask you which mode to use.
kernel /vmlinuz-linux root=/dev/sda1 ro vga=ask
Now reboot. GRUB will now present a list of suitable codes to use and the option to scan for even more.
You can pick the code you would like to use (do not forget it, it is needed for the next step) and boot using it.
Now replace ask in the kernel line with the correct one you have picked.
e.g. the kernel line for  1680x1050x32 would be:
kernel /vmlinuz-linux root=/dev/sda1 ro vga=0x369
- Install Template:Package Official from [community].
- Run Template:Codeline as root.
- Pick up the code corresponding to the desired resolution.
- Use the 6 digit code with 0x prefix in Template:Codeline kernel option in Template:Filename. Or convert it to decimal to avoid the use of 0x prefix.
Example output of hwinfo:
Mode 0x0364: 1440x900 (+1440), 8 bits Mode 0x0365: 1440x900 (+5760), 24 bits
And the kernel line:
kernel /vmlinuz-linux root=/dev/sda1 ro vga=0x0365
- Install the Template:Package AUR package from the AUR that contains the vbetest tool (x86_64 users will need to use #hwinfo above).
- Run Template:Codeline as root
- Then note the number in [ ] corresponding to your desired resolution.
- Press 'q' to quit vbetest interactive prompt.
- Add 512 to the discovered value picked up above and use the total value to define the Template:Codeline parameter in the kernel options of Template:Filename.
- Reboot to enjoy the result
For example vbetest on one computer:
 1440x900 (256 color palette)  1440x900 (8:8:8)
So here the number you want is 357. Then, 357 + 512 = 869, so you will use vga=869. Add your value to the end of the kernel line in Template:Filename as shown below:
kernel /vmlinuz-linux root=/dev/sda1 ro vga=869
Naming by label
If you alter (or plan to alter) partition sizes from time to time, you might want to consider defining your drive/partitions by a label. You can label ext2, ext3, ext4 partitions by:
e2label </dev/drive|partition> label
The label name can be up to 16 characters long but cannot have spaces for GRUB to understand it. Then define it in your Template:Filename:
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro
You can enable password protection in the GRUB configuration file for operating systems you wish to have protected. Bootloader password protection may be desired if your BIOS lacks such functionality and you need the extra security.
First, choose a password you can remember and then encrypt it:
# grub-md5-crypt Password: Retype password: $1$ZOGor$GABXUQ/hnzns/d5JYqqjw
Then add your password to the beginning of the GRUB configuration file (the password must be at the beginning of the configuration file for GRUB to be able to recognize it):
# general configuration timeout 5 default 0 color light-blue/black light-cyan/blue password --md5 $1$ZOGor$GABXUQ/hnzns/d5JYqqjw
Then for each operating system you wish to protect, add the Template:Codeline command:
# (0) Arch Linux title Arch Linux lock root (hd0,1) kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro initrd /boot/initramfs-linux.img
Restart with named boot choice
If you realize that you often need to switch to some other non-default OS (e.g. Windows) having to reboot and wait for the GRUB menu to appear is tedious. GRUB offers a way to record your OS choice when restarting instead of waiting for the menu, by designating a temporary new default which will be reset as soon as it has been used.
Supposing a simple Template:Filename setup like this:
Arch is the default (0). We want to restart in to Windows. Change Template:Codeline to Template:Codeline -- this will record the current default in a Template:Filename file in the GRUB directory whenever the savedefault command is used. Now add the line Template:Codeline to the bottom of the Windows entry. Whenever Windows is booted, it will reset the default to Arch, thus making changing the default to Windows temporary.
Now all that is needed is a way to easily change the default manually. This can be accomplished using the command Template:Codeline. So, to reboot into Windows, enter the following command:
LILO and GRUB interaction
If the LILO package is installed on your system, remove it with
as some tasks (e.g. kernel compilation using Template:Codeline) will make a LILO call, and LILO will then be installed over GRUB. LILO may have been included in your base system, depending on your installer media version and whether you selected/deselected it during the package selection stage.
GRUB boot disk
First, format a floppy disk:
fdformat /dev/fd0 mke2fs /dev/fd0
Now mount the disk:
mount -t ext2 /dev/fd0 /mnt/fl
Install GRUB to the disk:
grub-install --root-directory=/mnt/fl '(fd0)'
Copy your Template:Filename file to the disk:
cp /boot/grub/menu.lst /mnt/fl/boot/grub/menu.lst
Now unmount your floppy:
Now you should be able to restart your computer with the disk in the drive and it should boot to GRUB. Make sure that your floppy disk is set to have higher priority than your hard drive when booting in your BIOS first, of course.
See also: Super GRUB Disk
Content moved to Boot_Debugging
GRUB Error 17
The first check to do is to unplug any external drive. Seems obvious, but sometimes we get tired ;)
If your partition table gets messed up, an unpleasant "GRUB error 17" message might be the only thing that greets you on your next reboot. There are a number of reasons why the partition table could get messed up. Commonly, users who manipulate their partitions with GParted -- particularly logical drives -- can cause the order of the partitions to change. For example, you delete Template:Filename and resize Template:Filename, then finally re-create what used to be Template:Filename only now it appears at the bottom of the list, Template:Filename for example. Although the physical order of the partitions/logical drives has not changed, the order in which they are recognized has changed.
Fixing the partition table is easy. Boot from your Arch CD/DVD/USB, login as root and fix the partition table:
# fdisk /dev/sda
Once in disk, enter e[x]tra/expert mode, [f]ix the partition order, then [w]rite the table and exit.
grub> root (hd0,6) grub> setup (hd0) grub> quit
See [this page] for a more in-depth summary of this section.
/boot/grub/stage1 not read correctly
If you see this error message while trying to setup grub and you are not using a fresh partition table, it is worth checking it.
# fdisk -l /dev/sda
This will show you the partition table for /dev/sda. So check here, whether the "Id" values of your partitions are correct. The "System" column will show you the description of the "Id" values.
If your boot partition is marked as being "HPFS/NTFS", for example, then you have to change it to "Linux". To do this, go to fdisk,
# fdisk /dev/sda
change a partition's system id with [t], select you partition number and type in the new system id (Linux = 83). You can also list all available system ids by typing "L" instead of a system id.
If you have changed a partitions system id, you should [v]erify your partition table and then [w]rite it.
Now try to setup grub again.
[Here] is the forum post reporting this problem.
Accidental install to a Windows partition
If you accidentally install GRUB to a Windows partition, GRUB will write some information to the boot sector of the partition, erasing the reference to the Windows bootloader. (This is true for NTLDR the bootloader for Windows XP and earlier, unsure about later versions).
To fix this you will need to use the Windows Recovery Console for your Windows release. Because many computer manufacturers do not include this with their product (many choose to use a recovery partition) Microsoft has made them available for download. If you use XP, look at this page to be able to turn the floppy disks to a Recovery CD. Boot the Recovery CD (or enable Windows Recovery mode) and run Template:Codeline to repair the partition boot sector. After this, you will have to install GRUB again---this time, to the MBR, not to the Windows partition---to boot Linux.
Once you have selected and entry in the boot menu, you can edit it by pressing key Template:Keypress. Use tab-completion if you need to to discover devices then Template:Keypress to exit. Then you can try to boot by pressing Template:Keypress.
If an error is raised mentioning Template:Filename during installation or boot, run:
# grub-install --recheck /dev/sda
to force GRUB to recheck the device map, even if it already exists. This may be necessary after resizing partitions or adding/removing drives.
If you have opened a sub-menu with the list of all operating systems configured in GRUB, selected one, and upon restart, you still booted your default OS, then you might want to check if you have the line:
GRUB fails to find or install to any virtio /dev/vd* or other non-BIOS devices
I had trouble installing GRUB while installing Arch Linux in an virtual KVM machine using a virtio device for hard drive. To install GRUB, I figured out the following: Enter a virtual console by typing Template:Keypress + Template:Keypress + Template:Keypress or any other F-key for a free virtual console. This assumes that your root file system is mounted in the folder Template:Filename and the boot file system is either mounted or stored in the folder Template:Filename.
1. Assure that all needed GRUB files is present in your boot directory (assuming it is mounted in Template:Filename folder), by issuing the command:
# ls /mnt/boot/grub
2. If the Template:Filename folder already contains all the needed files, jump to step 3. Otherwise, do the following commands (replacing Template:Codeline, Template:Codeline and Template:Codeline with the real paths and file names). You should also have the Template:Filename file written to this folder:
# mkdir -p /mnt/boot/grub # if the folder is not yet present # cp -r /boot/grub/stage1 /boot/grub/stage2 /mnt/boot/grub # cp -r your_kernel your_initrd /mnt/boot
3. Start the GRUB shell with the following command:
# grub --device-map=/dev/null
device (hd0) /dev/vda root (hd0,0) setup (hd0) quit
5. If GRUB reports no error messages you probably are done.