Skip to contentSkip to conversation

how to build a grub2 floppy with fs adventure

DISCUSSION adrian15 1 participant 1 message Jun 2, 2007

lore
Share & tools
lore

adrian15

author
#0 lore raw

You can advice me to run easier commands.
Here is my experience.

I do not want to install grub2 in my production environment so I plan to install into a floppy. The cat and dd way of install grub ( cat boot.img core.img | dd of=foo.img seek=0 conv=notrunc ) does not convince me because I want to be able to read a filesystem from my grub2, i.e., the floppy filesystem.

I've finally decided myself to use grub-install command from the
compiled sources directory ( In my system it is:
/home/adrian/Desktop/gnu/grub2/grub2_2007_05_31

1st problem: no core.img
==========================
The first problem is that no core.img is available once you run 'make'.
So I build one core.img like this:

./grub-mkimage -d ./ -o core.img

Once I have the come.img, I try to use grub-install, I finally found this to work:

./grub-install --root-directory=/media/floppy --modules=*.mod --grub-setup=./grub-setup --grub-mkimage=./grub-mkimage --grub-mkdevicemap=./grub-mkdevicemap --grub-probe=./grub-probe /dev/fd0

where the /media/floppy is the place where I mount my floppy and, of course, the floppy has to be mounted!!! (I think the grub-legacy's grub-install did mount whatever was needed automatically although I am not very sure about that.)

2nd problem: grub-probe and partmap module
=============================================
Then the grub-probe command complained about a partmap module not being found so I decided to comment these lines from ./grub-install :

# Then the partition map module. #partmap_module=$grub_probe --target=partmap --device-map=${device_map} ${grubdir}
#if test "x$partmap_module" = x -a "x$modules" = x; then
# echo "Auto-detection of a partition map module failed." 1>&2
# echo "Please specify the module with the option \`--modules'
explicitly." 1>&2
# exit 1
#fi

3rd problem: grub-install did complain about not finding:
/usr/local/lib/grub/i386-pc
===========================================================
so I created it as a link to /home/adrian/Desktop/gnu/grub2/grub2_2007_05_31 (compiled sources dir)

4th problem:
=============
In order to fix the /usr/local/lib/grub/i386-pc problem I invented
myself another option for grub-install called --pkglibdir so that I could specify the directory myself.

However I think that other grub-install subprograms such as grub-probe or grub-mkimage also tried to find that /usr/local/lib/grub/i386-pc folder which it is annoying.

This is why I did the link trick.

It works!
=============

Finally I unmounted the floppy and tried to run it from qemu... it worked!

adrian15