GRUB Legacy

From ArchWiki
Revision as of 16:18, 7 June 2013 by Gm5729 (talk | contribs)
Jump to: navigation, search

zh-CN:GRUB Legacy Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

GRUB Legacy is a multiboot bootloader previously 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.

Note: GRUB Legacy has been deprecated and replaced by GRUB version 2.x in Arch Linux. See the news here. Users are recommended to switch to GRUB2 or Syslinux instead. See #Upgrading to GRUB2 below.


GRUB Legacy has been dropped from the official repositories in favor of GRUB version 2.x. grub-legacyAUR is still available from the AUR.

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.

Upgrading to GRUB2

Is upgrading necessary?

The short answer is No. GRUB legacy will not be removed from your system and will stay fully functional.

However, as any other packages which are not supported anymore, bugs are unlikely to be fixed. So you should consider upgrading to GRUB version 2.x, or one of the other supported Boot Loaders.

GRUB legacy does not support GPT disks, Btrfs filesystem and UEFI firmwares.

How to upgrade

Upgrade from GRUB Legacy to GRUB version 2.x is the much same as installing GRUB on a running Arch Linux. Detailed instructions is covered here.

  2. +-------------------------------------------------+
  3. | 640x480 800x600 1024x768 1280x1024
  4. ----+--------------------------------------------
  5. 256 | 0x301=769 0x303=771 0x305=773 0x307=775
  6. 32K | 0x310=784 0x313=787 0x316=790 0x319=793
  7. 64K | 0x311=785 0x314=788 0x317=791 0x31A=794
  8. 16M | 0x312=786 0x315=789 0x318=792 0x31B=795
  9. +-------------------------------------------------+
  10. for more details and different resolutions see


GRUB Error 17

Note: the solution below works also for GRUB Error 15

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 /dev/sda6 and resize /dev/sda7, then finally re-create what used to be /dev/sda6 only now it appears at the bottom of the list, /dev/sda9 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.

You can verify that the partition table was indeed fixed by issuing an fdisk -l. Now you just need to fix GRUB. See the #Bootloader installation section above.

Basically you need to tell GRUB the correct location of your /boot then re-write GRUB to the MBR on the disk.

For example:

# grub
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 set up 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 set up 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 fixboot 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.

See further discussion here.

Edit GRUB entries in the boot menu

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.

Note: These settings will not be saved. error

If an error is raised mentioning /boot/grub/ 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.

KDE reboot pull-down menu fails

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:

default saved

in /boot/grub/menu.lst.

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 or any other F-key for a free virtual console. This assumes that your root file system is mounted in the folder /mnt and the boot file system is either mounted or stored in the folder /mnt/boot.

1. Assure that all needed GRUB files is present in your boot directory (assuming it is mounted in /mnt/boot folder), by issuing the command:

# ls /mnt/boot/grub

2. If the /mnt/boot/grub folder already contains all the needed files, jump to step 3. Otherwise, do the following commands (replacing /mnt, your_kernel and your_initrd with the real paths and file names). You should also have the menu.lst 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

4. Enter the following commands. Replace /dev/vda, and (hd0,0) with the correct device and partition corresponding to your setup.

device (hd0) /dev/vda
root (hd0,0)
setup (hd0)

5. If GRUB reports no error messages, then you probably are done. You also need to add appropriate modules to the ramdisk. For more information, please refer to the KVM guide on Preparing an (Arch) Linux guest

See also