OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Jan 19, 2019 2:25 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Create ISO image with GRUB2
PostPosted: Wed Jun 22, 2011 6:34 am 
Offline

Joined: Fri Mar 06, 2009 12:18 pm
Posts: 12
Location: Poland
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

_________________
LukOS


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Wed Jun 22, 2011 9:06 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 03, 2008 4:13 am
Posts: 130
Location: Ogre, Latvia, EU
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
}

_________________
If something looks overcomplicated, most likely it is.


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Wed Jun 22, 2011 10:04 am 
Offline

Joined: Fri Mar 06, 2009 12:18 pm
Posts: 12
Location: Poland
Thanks. On qemu is probably OK, but on bochs, grub print:
Code:
error: unknown filesystem.
Entering rescue mode...

_________________
LukOS


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Wed Jun 22, 2011 1:23 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1067
Location: Tartu, Estonia
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.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Thu Jun 23, 2011 5:17 am 
Offline

Joined: Fri Mar 06, 2009 12:18 pm
Posts: 12
Location: Poland
:(
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.

_________________
LukOS


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Mon Dec 26, 2011 11:44 am 
Offline
Member
Member

Joined: Wed Nov 10, 2010 10:55 pm
Posts: 61
How was this resolved? I'm having the same trouble making a grub 2 boot iso following the wiki.


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Mon Dec 26, 2011 12:00 pm 
Offline

Joined: Fri Mar 06, 2009 12:18 pm
Posts: 12
Location: Poland
I wrote own bootloader :D

_________________
LukOS


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Tue Dec 27, 2011 9:24 am 
Offline
Member
Member

Joined: Sat Sep 29, 2007 5:43 pm
Posts: 127
Location: Amsterdam, The Netherlands
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.


Top
 Profile  
 
 Post subject: Re: Create ISO image with GRUB2
PostPosted: Thu Dec 29, 2011 1:49 pm 
Offline
Member
Member

Joined: Wed Nov 10, 2010 10:55 pm
Posts: 61
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
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group