GRUB: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
Line 35: Line 35:


mkdir tmp
mkdir tmp
grub-mkimage -p /boot -o tmp/core.img biosdisk iso9660 multiboot # Generate the core image
grub-mkimage -p /boot -o tmp/core.img biosdisk iso9660 multiboot sh # Generate the core image
cat /usr/lib/grub/i386-pc/cdboot.img tmp/core.img > eltorito.img # You just replace stage2_eltorito with eltorito.img
cat /usr/lib/grub/i386-pc/cdboot.img tmp/core.img > eltorito.img # You just replace stage2_eltorito with eltorito.img


Line 71: Line 71:
| Allows GRUB 2 to look on the LiveCD for different files.
| Allows GRUB 2 to look on the LiveCD for different files.
|-
|-
|- '''sh'''
| This module allows GRUB to parse the configuration file.
|}
|}



Revision as of 22:39, 13 March 2010

This page is a work in progress.
This page may thus be incomplete. Its content may be changed in the near future.

GRUB 2 is the GNU Project's next-generation bootloader. It has a more complete feature set than GRUB 0.97 (commonly referred to as "GRUB Legacy"). Still, all things considered, GRUB Legacy is more mature and most of the available documentation is for GRUB Legacy (hence the brief page).


History

GRUB 2 started its life as the PUPA (note the pun) research project and was rewritten from the ground up. Since then GRUB 2 (actually at time of update 1.97) has grown more stable and even hobby operating systems are starting to make use of the new bootloader instead of GRUB Legacy.

Features

  • Basic scripting support
  • GUI (better bootsplash support, custom colors, custom themes, ...)
  • Memory management
  • Cleaner design
  • Better portability
  • Internationalization
  • Rescue mode

Upgrading for GRUB Legacy

WARNING: These steps have not been tested very well yet. Use at your own risk!

Since GRUB 2 is very different from GRUB Legacy, the directions for getting your kernel up and running are different. This section gives you an overview of the process you need to go through when you want to have GRUB 2 load your kernel.


It's actually rather simple to create a GRUB2 image:

NOTE: These instructions assume you already have GRUB2 either built or installed

ISO instructions

mkdir tmp
grub-mkimage -p /boot -o tmp/core.img biosdisk iso9660 multiboot sh # Generate the core image
cat /usr/lib/grub/i386-pc/cdboot.img tmp/core.img > eltorito.img # You just replace stage2_eltorito with eltorito.img

# Now just use genisoimage, or mkisofs to generate an ISO image!


Floppy instructions

mkdir tmp
grub-mkimage -p /boot -o tmp/core.img multiboot # This should work.. I hope :D

Let's go through those grub-mkimage options:

-p By default, GRUB 2 looks in /boot/grub for its configuration file. -p changes this.
-o Like so many other GNU tools, grub-mkimage uses -o to set the output file. By default, it's stdout.
multiboot GRUB 2 differs from GRUB Legacy in that to implement all but the most basic functionality, the user must load modules -- little bits of code

that add things like the ability to use a different file system, use a VGA font, etc.. Anyway, this module is required to load multiboot modules.

biosdisk This module is required for GRUB 2 to be able to boot from a LiveCD.
iso9660 Allows GRUB 2 to look on the LiveCD for different files.
This module allows GRUB to parse the configuration file.

GRUB 2, like GRUB Legacy, needs a configuration file to find your kernel. Unlike GRUB Legacy, it's called "grub.cfg". Also, the syntax for the configuration file is a bit different.

Here's a sample configuration file (NOTE: This file should be placed into the /boot folder of your disk image, and be named grub.cfg):

set timeout=15

set default=0 # Set the default menu entry

menuentry "My OS Name here" {
  multiboot /boot/kernel-file   # The multiboot command replaces the kernel command
  boot
}

That's it. Copy these files to a disk image, pop it in an emulator, and you're finished!

See Also

External Links