Creating floppy image with grub without floppydrive :)

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
dtoch
Posts: 3
Joined: Mon Apr 09, 2007 9:01 am

Creating floppy image with grub without floppydrive :)

Post by dtoch »

Hi!

May be some one will need this like me.

How to create bootable image of floppy disk with grub:

1. As writen on http://www.osdev.org/osfaq2/index.php/D ... er%20Linux creating two files, which will be our virtual floppies
# dd if=/dev/zero of=floppy1.img bs=512 count=2880
# dd if=/dev/zero of=floppy2.img bs=512 count=2880

2. Now creating ext2(or which you need) filesystem on floppy2.img
# mke2fs floppy2.img

3. Next, mount it:
# mount -t ext2 -o loop floppy2.img /mnt/

4. Copy grub stages:

# mkdir /mnt/boot
# cp /boot/grub/stage1 /boot/grub/stage2 /mnt/boot/

5. Unmounting it:
# sync
# umount /mnt/

6. Lets make floppy1.img bootable:
# dd if=/boot/grub/stage1 of=floppy1.img bs=512 count=1 conv=notrunc
# dd if=/boot/grub/stage2 of=floppy1.img bs=512 conv=notrunc

7. Booting in qemu:
# qemu -fda floppy1.img -fdb floppy2.img

After qemu starts you will see grub-shell prompt. Write:

8. > install (fd1)/boot/stage1 (fd1) (fd1)/boot/stage2

Reboot.

Now we can copy some kernel to floppy2.img to check our grub:

# mount -t ext2 -o loop floppy2.img /mnt/
# cp /usr/src/linux/arch/i386/boot/bzImage /mnt/boot/bzImage
(WARNING! Kernel may not fit in floppy image!)

# sync
# umount /mnt/

# qemu -fda floppy2.img

In grub-shell:
> kernel (fd0)/boot/bzImage
> boot

Thats all. :)
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

There is no need to "sync" before you "umount" as "umount" will sync the drive anyway. Not on Linux anyway.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
dtoch
Posts: 3
Joined: Mon Apr 09, 2007 9:01 am

Post by dtoch »

old habit. :)
Post Reply