Linux floppy image creation problem

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
NOTNULL

Linux floppy image creation problem

Post by NOTNULL »

Hi all,
I have gone through http://www.osdev.org/osfaq2/index.php/Disk%20Images%20Under%20Linux and created floppy image using the loop0 device. I write my promary bootloader to the first 512 bytes of the loop device using the command,

Code: Select all

dd if=boot.bin of=/dev/loop0 bs=512 skip=0.
Then, I copy boot2.bin and kernel.bin to /mnt/myfloppy directory. The 'floppya' in bochs points to /dev/loop0. I just wanted to know, should i 'dd' boot.bin and copy boot2.bin, kernel.bin to /mnt/myfloppy, whenever I recompile my kernel? Because, the change that I make in the kernel is not reflected in the bochs, when i just copy kernel.bin. Also, if i do all the steps, sometimes, the change is not reflected.

Thanks in advance.
User avatar
Solar
Member
Member
Posts: 7635
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Linux floppy image creation problem

Post by Solar »

Perhaps you're falling for Linux buffering the output. Changes are not written to devices immediately, but when it's convenient. Try to unmount the image on the Linux side before reading it from the Bochs side.
Every good solution is obvious once you've found it.
NOTNULL

Re:Linux floppy image creation problem

Post by NOTNULL »

Solar wrote: Perhaps you're falling for Linux buffering the output. Changes are not written to devices immediately, but when it's convenient. Try to unmount the image on the Linux side before reading it from the Bochs side.
If i unmount the image, will bochs be able to read it? Or do you mean by unmounting and mounting it again before running bochs? Is there any way to forcely write the changes to the image?
zyp

Re:Linux floppy image creation problem

Post by zyp »

You have to unmount the image before running bochs.
Bochs reads the image, and not the mounted file system.
User avatar
Solar
Member
Member
Posts: 7635
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Linux floppy image creation problem

Post by Solar »

NOTNULL wrote: If i unmount the image, will bochs be able to read it?
As zyp said, Bochs is reading the image, not the /mnt/myfloppy directory.
Is there any way to forcely write the changes to the image?
Yes - by unmounting it. ;)
Every good solution is obvious once you've found it.
Curufir

Re:Linux floppy image creation problem

Post by Curufir »

Is there any way to forcely write the changes to the image?
Use the sync command.
NOTNULL

Re:Linux floppy image creation problem

Post by NOTNULL »

Curufir wrote: Use the sync command.
I tried by unmounting /mnt/myfloppy, it worked. But, when I use sync command, I face some strange problems like ldtr.valid=0, my OS getting rebooted in bochs, etc. Could you please explain me, why such strange thing happens in case of sync command?
Curufir

Re:Linux floppy image creation problem

Post by Curufir »

'sync' just flushes the filesystem caches out to disk, it doesn't unmount any filesystems. Bochs can't read a mounted filesystem.

If you're just changing one file on the image then you'd be much better off using mtools (FAT images) or e2tools (ext2fs images) to inject the file into the image. That way you don't have to bother with any mounting. Since they don't require root permissions they also fit quite nicely into a makefile.
Post Reply