Page 1 of 1

Create ISO image with GRUB2

Posted: Wed Jun 22, 2011 6:34 am
by lukasz1235
Hi!
I'm trying to create an iso image with GRUB2. I use these commands:

Code: Select all

grub-mkimage -p /boot -o tmp/core.img -O i386-pc biosdisk iso9660 multiboot configfile
cat /usr/lib/grub/i386-pc/cdboot.img tmp/core.img > eltorito.img
My /boot/grub.cfg:

Code: Select all

set timeout=15
set default=0
 
menuentry "LukOS"
{
   multiboot /boot/LukOS.elf
   boot
} 
And GRUB2 write:

Code: Select all

error: "prefix" is not set.
error: no menuentry definition.
error: syntax error.
error: Incorrect command.
error: syntax error.
How to create a bootable iso image with grub2?

PS.

Code: Select all

$ grub-mkimage --version
grub-mkimage (GRUB) 1.99-6

Re: Create ISO image with GRUB2

Posted: Wed Jun 22, 2011 9:06 am
by Velko
I think, easiest way is to use GRUB2's grub-mkrescue utility:

Code: Select all

grub-mkrescue -o velkos.iso runimage/
Contents of runimage/ directory:

Code: Select all

runimage/boot/grub/grub.cfg
runimage/boot/kernel.bin
Contents of grub.cfg:

Code: Select all

set default=0
set timeout=0

menuentry "VelkOS" {
        set root='(hd96)'
        multiboot /boot/kernel.bin
}

Re: Create ISO image with GRUB2

Posted: Wed Jun 22, 2011 10:04 am
by lukasz1235
Thanks. On qemu is probably OK, but on bochs, grub print:

Code: Select all

error: unknown filesystem.
Entering rescue mode...

Re: Create ISO image with GRUB2

Posted: Wed Jun 22, 2011 1:23 pm
by xenos
lukasz1235 wrote:Hi!
I'm trying to create an iso image with GRUB2. I use these commands:
I think you need to include the sh module to enable parsing of the config file:

Code: Select all

grub-mkimage -p /boot -o tmp/core.img -O i386-pc biosdisk iso9660 multiboot configfile sh
cat /usr/lib/grub/i386-pc/cdboot.img tmp/core.img > eltorito.img
See GRUB2.

Re: Create ISO image with GRUB2

Posted: Thu Jun 23, 2011 5:17 am
by lukasz1235
:(

Code: Select all

$ grub-mkimage -p /boot -o tmp/core.img -O i386-pc biosdisk iso9660 multiboot configfile sh
grub-mkimage: error: cannot stat /usr/lib/grub/i386-pc/sh.mod.
From GRUB changelog:
* util/grub-mkrescue.in (make_image): Remove sh module, which has been merged back into normal.

Re: Create ISO image with GRUB2

Posted: Mon Dec 26, 2011 11:44 am
by dschatz
How was this resolved? I'm having the same trouble making a grub 2 boot iso following the wiki.

Re: Create ISO image with GRUB2

Posted: Mon Dec 26, 2011 12:00 pm
by lukasz1235
I wrote own bootloader :D

Re: Create ISO image with GRUB2

Posted: Tue Dec 27, 2011 9:24 am
by StephanvanSchaik
Hi,

For those who want to create an ISO image containing GRUB 2, you might attempt to use the following commands as listed in one of my Makefiles:

Code: Select all

bootcd:
	@echo Creating bootable CD image...
	@grub-mkimage --format=i386-pc --prefix="(cd)" --output=bin/core.img \
		--config="boot/default.cfg" loadenv biosdisk part_msdos part_gpt fat ntfs \
		ext2 ntfscomp iso9660 loopback search linux boot minicmd cat cpuid chain \
		halt help ls reboot echo test configfile normal sleep memdisk tar font \
		gfxterm gettext true vbe vga video_bochs video_cirrus multiboot multiboot2
	@cat /usr/lib/grub/i386-pc/cdboot.img bin/core.img > bin/grub.img
	@genisoimage -graft-points -input-charset utf8 -A "Label" -quiet -R -b \
		boot/grub/grub.img -no-emul-boot -boot-load-size 4 -boot-info-table \
		-o bootcd.iso \
		boot/kernel=bin/kernel \
		boot/grub/grub.cfg=boot/grub.cfg \
		boot/grub/grub.img=bin/grub.img
You might check out the OSDev wiki to figure out how most of these commands work. The rest should be pretty self-explanatory.


Yours faithfully,
S.J.R. van Schaik.

Re: Create ISO image with GRUB2

Posted: Thu Dec 29, 2011 1:49 pm
by dschatz
I was able to get a bootable grub 2 disc on the latest ubuntu server by doing the following:

Code: Select all

grub-mkrescue -o bootable.iso iso/
iso directory structure:

Code: Select all

iso/
    boot/
        grub/
            grub.cfg
        kernel.bin
grub.cfg:

Code: Select all

set default=0
set timeout=0

menuentry "OS" {
              multiboot /boot/kernel.bin
              boot
}