Grub into an image

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
The_Legend

Grub into an image

Post by The_Legend »

Hi,

I can't figure out how to install grub into an image directly.
Would I have to do everything on a real floppy and copy
an image from it??? I hope not!
K.J.

Re: Grub into an image

Post by K.J. »

Let me see, when I first installed GRUB to a floppy for booting Linux(I did this about 7 months ago), I first went to the command prompt and did:
info grub

What I found was that you could use a utility that comes with GRUB or you could use dd. Looking at the info page I find:
cd /boot/grub
dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1


/boot/grub needs to have stage1 and stage2 in it for this to work. You should be able to change the of=/dev/fd0 to your (formated)floppy image.

Hope that helps,
K.J.
The_Legend

Re: Grub into an image

Post by The_Legend »

But doesn't grub need to configure at least stage1? or is it just copying the files like those dd's when using the grub shell with root (fd0) and setup (fd0)?
K.J.

Re: Grub into an image

Post by K.J. »

Okay, here's what I found in the OSD kernel readme:

1. Get a floppy formatted with a filesystem that GRUB recognizes,
  such as FAT (DOS/Windows) or ext2. On this floppy, create the
  subdirectory /boot/grub/

2. Copy the files STAGE1 and STAGE2 to this subdirectory. If
  you have a MENU.LST file, copy it to this subdirectory.

3. Concatenate the STAGE1 and STAGE2 files into one:
       (DOS)   copy /b stage1 + stage2 boot
       (UNIX)  cat stage1 stage2 >boot

4. Get a second, blank floppy disk, and write the merged GRUB
  file directly to this disk:
       (DOS)                           (UNIX)
       rawrite boot a:                 cat boot >/dev/fd0
               -OR-
       partcopy boot 0 168000 -f0

  PARTCOPY will give an error message because the file BOOT
  is much shorter than 0x168000 bytes, but this is OK.

5. Boot GRUB from the second floppy disk. Eject the second disk
  and insert the first, formatted floppy.

6. Type
       setup (fd0)

  GRUB is now installed on the formatted floppy and ready to
  boot.


K.J.
K.J.

Re: Grub into an image

Post by K.J. »

BTW, you should be able to do all of with a floppy image if you're using mtools.

K.J.
The_Legend

Re: Grub into an image

Post by The_Legend »

Well, I'm using ext2fs, I'll have to mount with loopback, but that shouldn't be a problem.

Okay, I'll have to use two images and Bochs ...
K.J.

Re: Grub into an image

Post by K.J. »

Don't know if you've done it yet, but I have. I used two images and Bochs. What I did find was that the GRUB that is with my distrobution(Redmond/Lycoris Linux) seemed to be a costum build that didn't work with the instructions from above. But I was able to do it fine using the stage1 and stage2 included in osd.zip( http://www.execpc.com/~geezer/osd/index.htm ). Well, now I'm going to have to get my kernel to work with GRUB. ;)

K.J.
Post Reply