Create ISO image with GRUB2

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
lukasz1235
Posts: 12
Joined: Fri Mar 06, 2009 12:18 pm
Location: Poland
Contact:

Create ISO image with GRUB2

Post 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
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: Create ISO image with GRUB2

Post 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
}
If something looks overcomplicated, most likely it is.
lukasz1235
Posts: 12
Joined: Fri Mar 06, 2009 12:18 pm
Location: Poland
Contact:

Re: Create ISO image with GRUB2

Post by lukasz1235 »

Thanks. On qemu is probably OK, but on bochs, grub print:

Code: Select all

error: unknown filesystem.
Entering rescue mode...
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Create ISO image with GRUB2

Post 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.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
lukasz1235
Posts: 12
Joined: Fri Mar 06, 2009 12:18 pm
Location: Poland
Contact:

Re: Create ISO image with GRUB2

Post 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.
dschatz
Member
Member
Posts: 61
Joined: Wed Nov 10, 2010 10:55 pm

Re: Create ISO image with GRUB2

Post by dschatz »

How was this resolved? I'm having the same trouble making a grub 2 boot iso following the wiki.
lukasz1235
Posts: 12
Joined: Fri Mar 06, 2009 12:18 pm
Location: Poland
Contact:

Re: Create ISO image with GRUB2

Post by lukasz1235 »

I wrote own bootloader :D
StephanvanSchaik
Member
Member
Posts: 127
Joined: Sat Sep 29, 2007 5:43 pm
Location: Amsterdam, The Netherlands

Re: Create ISO image with GRUB2

Post 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.
dschatz
Member
Member
Posts: 61
Joined: Wed Nov 10, 2010 10:55 pm

Re: Create ISO image with GRUB2

Post 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
}
Post Reply