OSDev.org
https://forum.osdev.org/

Create ISO image with GRUB2
https://forum.osdev.org/viewtopic.php?f=1&t=23766
Page 1 of 1

Author:  lukasz1235 [ Wed Jun 22, 2011 6:34 am ]
Post subject:  Create ISO image with GRUB2

Hi!
I'm trying to create an iso image with GRUB2. I use these commands:
Code:
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:
set timeout=15
set default=0

menuentry "LukOS"
{
   multiboot /boot/LukOS.elf
   boot
}


And GRUB2 write:
Code:
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:
$ grub-mkimage --version
grub-mkimage (GRUB) 1.99-6

Author:  Velko [ Wed Jun 22, 2011 9:06 am ]
Post subject:  Re: Create ISO image with GRUB2

I think, easiest way is to use GRUB2's grub-mkrescue utility:
Code:
grub-mkrescue -o velkos.iso runimage/

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

Contents of grub.cfg:
Code:
set default=0
set timeout=0

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

Author:  lukasz1235 [ Wed Jun 22, 2011 10:04 am ]
Post subject:  Re: Create ISO image with GRUB2

Thanks. On qemu is probably OK, but on bochs, grub print:
Code:
error: unknown filesystem.
Entering rescue mode...

Author:  xenos [ Wed Jun 22, 2011 1:23 pm ]
Post subject:  Re: Create ISO image with GRUB2

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:
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.

Author:  lukasz1235 [ Thu Jun 23, 2011 5:17 am ]
Post subject:  Re: Create ISO image with GRUB2

:(
Code:
$ 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:
Quote:
* util/grub-mkrescue.in (make_image): Remove sh module, which has been merged back into normal.

Author:  dschatz [ Mon Dec 26, 2011 11:44 am ]
Post subject:  Re: Create ISO image with GRUB2

How was this resolved? I'm having the same trouble making a grub 2 boot iso following the wiki.

Author:  lukasz1235 [ Mon Dec 26, 2011 12:00 pm ]
Post subject:  Re: Create ISO image with GRUB2

I wrote own bootloader :D

Author:  StephanvanSchaik [ Tue Dec 27, 2011 9:24 am ]
Post subject:  Re: Create ISO image with GRUB2

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:
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.

Author:  dschatz [ Thu Dec 29, 2011 1:49 pm ]
Post subject:  Re: Create ISO image with GRUB2

I was able to get a bootable grub 2 disc on the latest ubuntu server by doing the following:
Code:
grub-mkrescue -o bootable.iso iso/

iso directory structure:
Code:
iso/
    boot/
        grub/
            grub.cfg
        kernel.bin

grub.cfg:
Code:
set default=0
set timeout=0

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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/