Installing grub2 onto floppy.

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
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

Installing grub2 onto floppy.

Post by HyperAssembler »

Hello,

I used the following code to install grub2 to floppy.

Code: Select all

KERNELFLOPPY=$1
sudo dd if=/dev/zero of=$1 bs=512 count=2880 conv=notrunc
sudo losetup /dev/loop0 $1
sudo mke2fs /dev/loop0
sudo mount -t ext2 /dev/loop0 /mnt/floppy
sudo grub-install --force --root-directory=/mnt/floppy /dev/loop0
sudo umount /mnt/floppy
sudo losetup -d /dev/loop0
It fails with:

Code: Select all

Installing for i386-pc platform.
grub-install: error: cannot open `/mnt/floppy/boot/grub/i386-pc/macbless.mod': No space left on device.
I googled for 2 hours and ended up with nothing but:

Code: Select all

grub-mkimage -O i386-pc -o temp.img
And it turned out that the size of temp.img surpassed 1.44M.

So is there no way to get grub2 on floppy?

Thanks.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Installing grub2 onto floppy.

Post by SpyderTL »

Without even looking,I'm going to say 'no'. :)

Even if you could, you wouldnt have any room left for an OS...
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
iansjack
Member
Member
Posts: 4708
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Installing grub2 onto floppy.

Post by iansjack »

SpyderTL wrote:Without even looking,I'm going to say 'no'. :)

Even if you could, you wouldnt have any room left for an OS...
That's a red herring; the OS doesn't have to reside on the same disk as Grub. Having said that, I believe the only solution is to use a 2.88 floppy.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Installing grub2 onto floppy.

Post by Combuster »

Grub legacy certainly is small enough to fit on a floppy together with an OS. I don't have grub2 (I decided to migrate straight to ReFind when the time came), but if you really need it and core isn't that bloated, you might want to look to see what modules it uses and eject about everything except the ext2 and multiboot ones. Maybe you end up with something small enough to fit in a few hundred kb eventually.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Installing grub2 onto floppy.

Post by xenos »

I'm not sure about how much space it would need on a floppy, but my GRUB2 CD image has a size of < 600kB - including a 80kB kernel file. It only has minimal GRUB2 modules (i386-pc, biosdisk, iso9660, multiboot, configfile - for a floppy you would want to replace iso9660 with a different file system driver, depending on whether you use fat12 or ext2).
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

Re: Installing grub2 onto floppy.

Post by HyperAssembler »

XenOS wrote:I'm not sure about how much space it would need on a floppy, but my GRUB2 CD image has a size of < 600kB - including a 80kB kernel file. It only has minimal GRUB2 modules (i386-pc, biosdisk, iso9660, multiboot, configfile - for a floppy you would want to replace iso9660 with a different file system driver, depending on whether you use fat12 or ext2).
I tried to specify modules grub2 uses by

Code: Select all

grub-install --boot-directory=/mnt/floppy --modules="normal part_msdos multiboot" /dev/loop0
according to wiki.
Still fails with the same message.

How to specify modules to load?
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

Re: Installing grub2 onto floppy.

Post by HyperAssembler »

iansjack wrote:
SpyderTL wrote:Without even looking,I'm going to say 'no'. :)

Even if you could, you wouldnt have any room left for an OS...
That's a red herring; the OS doesn't have to reside on the same disk as Grub. Having said that, I believe the only solution is to use a 2.88 floppy.
So I tried 2.88Mb by changing count=2880 to count=5760.
It still complains about not enough space.

I noticed that the core.img generated by grub-mkimage is just around 1.9MB so it should fit in 2.88MB floppy.

Does grub2 copy other stuff to floppy?(I assume that all the modules should be packed in core.img since it's generated by grub-mkimage)
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Installing grub2 onto floppy.

Post by xenos »

HyperAssembler wrote:How to specify modules to load?
Since I'm creating a CD image instead of a floppy image, the command is quite different:

Code: Select all

grub-mkimage -o /tmp/core.img -O i386-pc biosdisk iso9660 multiboot configfile
cat /usr/lib/grub/i386-pc/cdboot.img /tmp/core.img > iso/grub2/eltorito.img
rm /tmp/core.img
genisoimage -R -f -b boot/grub/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table -o run/boot.iso -graft-points nos/=iso/nos/ boot/grub/=iso/grub2/
There are also floppy instructions for GRUB 2, but I have not tried them.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

Re: Installing grub2 onto floppy.

Post by HyperAssembler »

Thanks everyone finally get it working. :D
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Installing grub2 onto floppy.

Post by Combuster »

Would you be so kind to post an explanation regarding to the solution? I'm sure there will be future people with the same problem.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

Re: Installing grub2 onto floppy.

Post by HyperAssembler »

I actually gave up on floppy.
Even for a 2.88M, there would be few space left for kernel.
So I followed the tutorial here and made myself an iso.
Simple, convenient and works like a charm.
Post Reply