Bootable El-Torito CD with GRUB Legacy: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
m (adding category)
Line 95: Line 95:
* http://www.geocities.com/imulgrew/grub_files.tar.gz - a package containing the GRUB stages including <tt>stage2_eltorito</tt>
* http://www.geocities.com/imulgrew/grub_files.tar.gz - a package containing the GRUB stages including <tt>stage2_eltorito</tt>
* ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz - get the source for GRUB Legacy and build it yourself
* ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz - get the source for GRUB Legacy and build it yourself

[[Category:Tutorials]]

Revision as of 15:05, 3 November 2008

Difficulty level

Beginner

This tutorial guides you through making a bootable CD .iso image with GRUB Legacy. We are going to create a El-Torito "no-emulation" bootable CD, which is different from a bootable CD emulating a floppy disc.

Requirements

You will need the following:

  • mkisofs, which is in fact superseeded by genisoimage.
  • A (Multiboot compliant) kernel that GRUB can boot.
  • The El-Torito GRUB Legacy stage2 file, called stage2_eltorito.

Ubuntu

In Ubuntu you can install the required software like this:

$ sudo aptitude install genisoimage grub

We need a place to store the files on the CD image:

$ cd                            # Go to your home directory.
$ mkdir -p isofiles/boot/grub

You now created an isofiles directory in your home folder and a boot/grub sub-folder inside that. We need the stage2 file. It is installed from the grub package. Just copy it:

$ cp /usr/lib/grub/i386-pc/stage2_eltorito ~/isofiles/boot/grub/

Windows

Look at this article about how to install and use mkisofs. We need a place to store the files on the CD image. Create a folder isofiles, which contains the sub-folder boot\grub needed by GRUB. We need the stage2 file. You can get it by downloading a package and unpack it using your favourite unpack application. Find the file stage2_eltorito and copy it to isofiles\boot\grub.

Install a kernel

Get a kernel of your own choosing and copy it to wherever you like inside the isofiles folder. Preferably it should be placed in the boot sub-folder. Now create a menu.lst file. It must be placed in the GRUB folder boot/grub and contain something like this:

default 0
#timeout 30

#title Boot from hard disk
#chainloader (hd0)+1

title My kernel
kernel /boot/kernel-file    # Edit it to the filename of your kernel.

Create the .iso image

In the following I use the command genisoimage, but you can change it to mkisofs if that is what its called on your system. Open a command prompt/terminal and go to where the isofiles folder is located. It is your home directory on Ubuntu. Issue the command:

genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4
            -boot-info-table -o bootable.iso isofiles

Now you have a file called bootable.iso. Test it using your favourite emulator or burn it to a CD and test on a real computer. I will just explain the command line arguments we used for genisoimage:

  • -R is using the Rock Ridge protocol, which enables lower-case filenames on the CD.
  • -b option takes the filename of the El-Torito boot file.
  • -no-emul-boot enables no emulation El-Torito boot.
  • -boot-load-size option specifies the number of 512-bytes sectors to load.
  • -boot-info-table patches the El-Torito boot file to contain info about the CD image.
  • -o gives the output .iso image filename.

Advanced stuff

Give it a label

You want to label your CD image, so you can later recognize it when loading your CD. Just pass a -A command line argument to genisoimage followed by the name you want.

Make it be quiet

Some day you probably want to create an .iso image directly in your Makefile. If you don't like the output that genisoimage creates, just pass the command line argument -quiet.

Sometimes you get a warning about the input character set used. If that is a problem just pass the argument -input-charset ascii (or utf8 if that is what you use on your filesystem).

Make the image from different files and folders

When you are building your kernel the parts on the .iso image could be located at different paths. Here is an example:

· build/
  · my-kernel.elf
· src/
  · grub/
    · menu.lst
· thirdparty/
  · grub/
    · stage2_eltorito

You don't want to copy those files around in order to create the .iso image. Just use the -graft-points argument, like this:

genisoimage -graft-points ...other arguments...
            boot/my-kernel.elf=build/my-kernel.elf
            boot/grub/menu.lst=src/grub/menu.lst
            boot/grub/stage2_eltorito=thirdparty/grub/stage2_eltorito

Links