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

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (→‎Create the .iso image: converting list to table)
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(11 intermediate revisions by 9 users not shown)
Line 6:
You will need the following:
* [[mkisofs]], which is in fact superseeded by [[genisoimage]].
* A (Multiboot compliant) kernel that [[GRUB Legacy]] can boot.
* The El-Torito GRUB Legacy stage2 file, called <tt>stage2_eltorito</tt>.
 
=== Ubuntu/Debian ===
 
In Ubuntu or Debian you can install the required software like this:
 
<sourcesyntaxhighlight lang="bash">
sudo aptitudeapt-get install genisoimage grub
</syntaxhighlight>
</source>
 
We need a place to store the files on the CD image:
 
<sourcesyntaxhighlight lang="bash">
cd # Go to your home directory.
mkdir -p isofiles/boot/grub
</syntaxhighlight>
</source>
 
You now created an <tt>isofiles</tt> directory in your home folder and a <tt>boot/grub</tt> sub-folder inside that. We need the stage2 file. It is installed from the grub package. Just copy it:
 
<sourcesyntaxhighlight lang="bash">
cp /usr/lib/grub/i386-pc/stage2_eltorito ~/isofiles/boot/grub/
</syntaxhighlight>
</source>
 
=== Windows ===
Line 39:
 
<!-- Not really Bash, it's Grub scripting, but lang="bash" makes nice syntax highlighting. -->
<sourcesyntaxhighlight lang="bash">
default 0
#timeout 30
Line 48:
title My kernel
kernel /boot/kernel-file # Edit it to the filename of your kernel.
</syntaxhighlight>
</source>
 
In GRUB there's a concept called root. It's the disk drive or partition where you access the files, like the kernel image and modules. When booting from CD using <tt>stage2_eltorito</tt> you don't need to set the root as it is already set to "<tt>(cd)</tt>".
 
== Create the .iso image ==
Line 54 ⟶ 56:
In the following I use the command <tt>genisoimage</tt>, but you can change it to <tt>mkisofs</tt> if that is what its called on your system. Open a command prompt/terminal and go to where the <tt>isofiles</tt> folder is located. It is your home directory on Ubuntu. Issue the command:
 
<sourcesyntaxhighlight lang="bash">
genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4
-boot-info-table -o bootable.iso isofiles
</syntaxhighlight>
</source>
 
Now you have a file called <tt>bootable.iso</tt>. 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:
Line 89 ⟶ 91:
=== Give it a label ===
 
You want to label your CD image, so you can later recognize it when loading your CD. Just pass a '''-AV''' command line argument to genisoimage followed by the name you want.
 
=== Make it be quiet ===
Line 121 ⟶ 123:
You don't want to copy those files around in order to create the .iso image. Just use the '''-graft-points''' argument, like this:
 
<sourcesyntaxhighlight lang="bash">
genisoimage -graft-points # ...other arguments here...
boot/my-kernel.elf=build/my-kernel.elf
Line 127 ⟶ 129:
boot/grub/stage2_eltorito=thirdparty/grub/stage2_eltorito
modules/=build/modules/
</syntaxhighlight>
</source>
 
You can use both files and folders together with the -graft-points argument.
Line 135 ⟶ 137:
If you don't find a solution to your problem below, please ask in [http://forum.osdev.org/ the forums].
 
=== mkisofs says Uh oh, I getcant afind permissionthe deniedboot errorimage ===
 
The output of mkisofs looks like this:
 
<pre>
mkisofs: Uh oh, I cant find the boot image 'isofiles/boot/grub/stage2_eltorito' !
</pre>
 
This problem arises because mkisofs/genisoimage looks for its boot image as a subdirectory of the filesystem on the CD; make sure that the path you specify starts with 'boot/' rather than the name of your ISO directory ('isofiles/' in this example).
 
Source: [[topic:20102|this thread]]
 
=== I get a permission denied error in Linux ===
 
The output of genisoimage looks like this:
Line 146 ⟶ 160:
The problem is that the -boot-info-table command line argument patches the boot file to include information about the CD, but the boot file is not writable by genisoimage. GRUB needs the boot file to be patched in order to access the CD properly. The solution is to make it writable, like this:
 
<sourcesyntaxhighlight lang="bash">
chown myself isofiles/boot/grub/stage2_eltorito # Make sure you are the owner of the file. Replace "myself"
# with your username. Maybe you need to use sudo.
chmod u+w isofiles/boot/grub/stage2_eltorito # Make the file writable for the owner of the file (you).
</syntaxhighlight>
</source>
 
== See Also ==
Line 156 ⟶ 170:
* [[mkisofs]]
* [[Bootable CD]] - using floppy disk emulation
* [[GRUB]] - for info on using GRUB 2 to make a bootable CD with modern GRUB
 
=== Forum ===
* [[topic:19050|Thread about making your own .iso image from scratch without tools]]
=== External Links ===
 
* [http://www.geocities.com/imulgrew/grub_files.tar.gz Package containing the GRUB stages] (including <tt>stage2_eltorito</tt>)
* [ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz Source for GRUB Legacy] to build it yourself
Line 162 ⟶ 181:
[[Category:Tutorials]]
[[Category:Bootloaders]]
[[Category:GRUB]]