Hi !
I used to be coding my little piece of OS under windows, but now I am using Linux. Under windows, I used VFD to load a preinstalled grub image, then copied my kernel.bin to this virtual floppy and then everything was working fine. But under linux .. I have no idea how to do it.
I read some threads about how to make an iso from scratch using dd and such, I also found a page on the Wiki that explained how to use mkisofs but mkisofs can't find my grub.img when I use the -b option.. so for now, I am kinda stuck. Is there an *easy* way to just load my grub.img ( a 1.44 mb iso containing just grub), copy kernel.bin to it and then save the whole as a new iso ?
Thanks !
Virtual floppy with preinstalled Grub (linux)
Re:Virtual floppy with preinstalled Grub (linux)
Em, I don't know what filesystem this image is meant to be formatted as, but it sounds like you made the image to be read in Windows - so I'm guessing it's FAT? (If not, I'm sure you can work out how to change it!)
Create directory to mount the image to
Mount your grub.img as a filesystem of type vfat at /mnt/vfloppy
Copy your kernel.bin to the boot directory on that floppy (might not apply to you - depends on your GRUB setup)
Unmount your grub.img from /mnt/vfloppy
Should add your kernel.bin to the existing image, I think (I haven't tried it, but the theory should apply alright). If you want to add it to a fresh copy, then just copy your existing grub.img to another file and change the commands as appropriate.
If you use bochs, you can either specify this image as the source for the floppy drive, or you (theoretically, but the bochs docs recommend against it, IIRC) can mount it as above and then use that as the source.
Create directory to mount the image to
Code: Select all
mkdir /mnt/vfloppy
Copy your kernel.bin to the boot directory on that floppy (might not apply to you - depends on your GRUB setup)
Unmount your grub.img from /mnt/vfloppy
Code: Select all
mount -t vfat /path/to/your/grub.img /mnt/vfloppy
cp /path/to/your/kernel.bin /mnt/vfloppy/boot/
umount /mnt/vfloppy
If you use bochs, you can either specify this image as the source for the floppy drive, or you (theoretically, but the bochs docs recommend against it, IIRC) can mount it as above and then use that as the source.
Regards,
Angus [Óengus] 'Midas' Lepper
Angus [Óengus] 'Midas' Lepper
Re:Virtual floppy with preinstalled Grub (linux)
Thanks ! That seems to be working after all ^^ (I had actually tried something similar, but everytime I looked at the date of modification of grub.img, it was the same, so I had assumed that it wasn't modified...but it actually is !)
Now on with >real< OS programming problems ;p
Now on with >real< OS programming problems ;p
Re:Virtual floppy with preinstalled Grub (linux)
If you want to install grub into a fresh image from scratch you can also try this (requires loopback kernel support, needs to be done as root):
This is from a 64bit Gentoo box, grub source file's path may vary depending on your distro and whether it's i686/x86_64.
Code: Select all
dd if=/dev/zero of=~/grubdisk.img count=2880 bs=512 # Create disk image
losetup /dev/loop1 ~/grubdisk.img # Map image to device
mke2fs /dev/loop1 # format disk image
mount /dev/loop1 -t ext2 /boot # mount image device on boot
mkdir /boot/grub # install grub
cp /lib/grub/x86_64-pc/stage1 /boot/grub
cp /lib/grub/x86_64-pc/e2fs_stage1_5 /boot/grub
cp /lib/grub/x86_64-pc/stage2 /boot/grub
grub --no-floppy
>device (fd0) /dev/loop1
>geometry (fd0) 80 2 18
>root (fd0)
>setup (fd0)
>quit
umount /boot
losetup -d /dev/loop1