Grub2

Revision 13 as of 2009-06-17 03:28:28

Clear message

'GRand Unified Bootloader, version 2' (Grub 2) is the second version of GNU GRUB. It is a data-processing program making it possible to charge an operating system. It can start by itself of the systems compatible with standard POSIX (GNU/Linux, *BSD, Mac OS, etc) and has the capacity to connect towards another charger of starting for the systems noncompatible with standard POSIX.

More than one continuity of the project GRUB Legacy precedent, GRUB 2 is a complete rewriting. Based on the research project PUPA, the purpose of GRUB 2 is to be a more modular charger of starting and portable that its predecessor. Some of the aims had by GRUB 2 are as follows:

  • a graphic interface;
  • the loading of modules at the object time rather than to compilation;
  • portability towards various material architectures (BIOS, EFI, Coreboot…) ;
  • a mode of help takes again the hand in the event of error of loading. stage1.5 were eliminated;
  • correction in the management of the classification of the partitions, thing which could not be brought back in GRUB.

grub.cfg

NOTE: you can use the update-grub (or grub-mkconfig in SVN trunk) utility to generate a grub.cfg file for you

GRUB 2 uses new bashish scripting language that is used to build menus. At startup file grub.cfg will be read and executed.

Please note that partition numbering has been changed to start from 1 (in grub legacy it started from 0).

Here is an simple example:

|| # Timeout for menu set timeout=10

# Set default boot entry as Entry 0 set default=0

# Entry 0 - Load Linux kernel menuentry "My Linux Kernel on (hd0,1)" {

  • set root=(hd0,1) linux /vmlinuz root=/dev/hda1 initrd /initrd

}

# Entry 1 - Chainload another bootloader menuentry "Chainload my OS" {

  • set root=(hd0,3) chainloader +1

} ||

Themeing

The GRUB graphical menu supports themes that can customize the layout and appearance of the GRUB boot menu. The theme is configured through a plain text file that specifies the layout of the various GUI components (including the boot menu, timeout progress bar, and text messages) as well as the appearance using colors, fonts, and images.

Commands

As GRUB 2 has been totally re-written, there are now some commands you might be used to in GRUB legacy that don't exist in GRUB 2. Take a look at the Grub 2 Command's List here.

Recover Grub 2

* First, grab a copy of the latest Ubuntu LiveCD and boot it. * Open a terminal and type

sudo fdisk -l

* Now, you need to remember which device listed is your linux distribution, for reference, /dev/sda1 will be used. Now we need to mount the filesystem to /mnt

sudo mount /dev/sda1 /mnt

*If you have /boot on a separate partition, that need's to be mounted aswell. For reference, /dev/sda2 will be used.

sudo mount /dev/sda2 /mnt/boot

Make sure you don't mix these up, pay attention to the output of FDISK

  • Now mount the rest of your devices

sudo mount --bind /dev /mnt

* Now chroot into your system

sudo chroot /mnt

* Now you need to edit the /etc/default/grub file to fit your system...when that is done you need to run grub-update to create the configuration file.

Errors