OSDev.org
https://forum.osdev.org/

[SOLVED]: Building floppy.img
https://forum.osdev.org/viewtopic.php?f=1&t=23044
Page 1 of 1

Author:  LegendDairy [ Wed Jan 26, 2011 7:20 am ]
Post subject:  [SOLVED]: Building floppy.img

Hi,
I don't have a real floppy driver on my computer anymore, so I always make a floppy.img using "floppy.asc" and FASM. But now I need to store modules into the floppy image so I can use them with grub, but I have no clue how to edit the "floppy.asc" or any other file in there, Does anyone knows what I could do? Or is there maybe an easier way or something? I need to store "initrd.img" in there.

Thx.

SOLVED: I've you have the same problem look at my last post, I edited the "floppy.asc"-file and don't forget to edit the menu.lst file to add your module.

Author:  AJ [ Wed Jan 26, 2011 7:24 am ]
Post subject:  Re: [Help]: Building floppy.img

Hi,

What platform / tools are you using? If on Windows, you could use VFD to mount a floppy image, format it as FAT12 and then copy over your boot sector using partcopy. Your initRD can be copied as if the floppy image were a real floppy.

If you're using cygwin, you could use a combination of MTools / dd to achieve the same sort of thing.

Cheers,
Adam

Author:  LegendDairy [ Wed Jan 26, 2011 7:25 am ]
Post subject:  Re: [Help]: Building floppy.img

AJ wrote:
Hi,

What platform / tools are you using? If on Windows, you could use VFD to mount a floppy image, format it as FAT12 and then copy over your boot sector using partcopy. Your initRD can be copied as if the floppy image were a real floppy.

If you're using cygwin, you could use a combination of MTools / dd to achieve the same sort of thing.

Cheers,
Adam

I'm on Ubuntu

Author:  AJ [ Wed Jan 26, 2011 7:27 am ]
Post subject:  Re: [Help]: Building floppy.img

Hi,

In that case, the dd / MTools thing should still apply. In addition to these, you can also use losetup.

Cheers,
Adam

Author:  NickJohnson [ Wed Jan 26, 2011 8:38 am ]
Post subject:  Re: [Help]: Building floppy.img

Since you don't have the floppy image thing set up yet, I would personally recommend trying to set up an El-Torito CD image instead. You install the bootloader to a floppy image once, then use that floppy image along with the files you want on the disc to produce the CD image each time. That way, you effectively never run out of space on the boot media, you can do real hardware tests using CDs, and when you want to fetch files using your OS, you write a useful ATAPI driver instead of a now-obsolete floppy driver. There are instructions on the wiki for doing this.

Author:  egos [ Wed Jan 26, 2011 9:05 am ]
Post subject:  Re: [Help]: Building floppy.img

See readme.txt from last version of mkfloppy.zip.

For previous version you can use following examples:
GrubOnFloppy.zip
GrubOnFloppy-198.zip

Author:  LegendDairy [ Wed Jan 26, 2011 9:52 am ]
Post subject:  Re: [Help]: Building floppy.img

egos wrote:
See readme.txt from last version of mkfloppy.zip.

For previous version you can use following examples:
GrubOnFloppy.zip
GrubOnFloppy-198.zip

Is there a simple way the edit the files in GrubOnFloppy to add "initrd.img" from the conten-folder to the floppy-img.

Author:  Combuster [ Wed Jan 26, 2011 9:56 am ]
Post subject:  Re: [Help]: Building floppy.img

MTools? :wink:

Author:  LegendDairy [ Wed Jan 26, 2011 10:01 am ]
Post subject:  Re: [Help]: Building floppy.img

Combuster wrote:
MTools? :wink:

NVM I got it to work with GrubOnFloppy and FASM :D God I'm happy!

I edited the "floppy.asc" file so it would add my module in there :
Code:
include "mkfloppy.inc"



STAGE1_5 equ 0



file "content/boot/grub/stage1", 3

db "MKFLOPPY"

dw 512

db 1

dw 1

db 2

dw 14*512/32

dw 2*80*18

db 0F0h

dw 9

dw 18

dw 2

dd 0

dd 0

db 0

db 0

db 29h

dd 55555555h

db 11 dup 32

db "FAT12", 32, 32, 32

file "content/boot/grub/stage1": $, 512-$



if STAGE1_5

kernel_address=2000h

kernel_sector=fatstage_base/512

kernel_segment=200h

else

kernel_address=8000h

kernel_sector=stage2_base/512

kernel_segment=800h

end if



; store byte 0 at 40h ; boot_drive cell

store word kernel_address at 42h

store dword kernel_sector at 44h

store word kernel_segment at 48h



; fat1

db 0F0h, 0FFh, 0FFh, 9*512-3 dup 0



; fat2

db 0F0h, 0FFh, 0FFh, 9*512-3 dup 0



; root

dent kernel, "KERNEL  BIN", FA_ARC
dent module, "INITRD  IMG", FA_ARC

dent boot, "BOOT", FA_DIR

; ...

rb 33*512-$



defdir boot

{

dent grub, "GRUB", FA_DIR

}



defdir grub

{

if STAGE1_5

lent fatstage, "FAT_ST~1", FA_ARC, "fat_stage1_5"

end if

dent menu, "MENU    LST", FA_ARC

dent stage2, "STAGE2", FA_ARC

}



; data

stof kernel, "content/kernel.bin"
stof module, "content/initrd.img"

stod boot, root

stod grub, boot

if STAGE1_5

stof fatstage, "content/boot/grub/fat_stage1_5"

store dword fatstage_base/512+1 at fatstage_base+1F8h

store word (fatstage_size+511)/512-1 at fatstage_base+1FCh

store word 220h at fatstage_base+1FEh

end if

stof menu, "content/boot/grub/menu.lst"

stof stage2, "content/boot/grub/stage2"

store dword stage2_base/512+1 at stage2_base+1F8h

store word (stage2_size+511)/512-1 at stage2_base+1FCh

store word 820h at stage2_base+1FEh

; ...

rb 2*80*18*512-$
initrd=my module file

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/