Page 1 of 1

Creating floppy image with grub without floppydrive :)

Posted: Wed Apr 11, 2007 7:00 am
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. :)

Posted: Wed Apr 11, 2007 11:37 am
by mystran
There is no need to "sync" before you "umount" as "umount" will sync the drive anyway. Not on Linux anyway.

Posted: Thu Apr 12, 2007 12:51 am
by dtoch
old habit. :)