Page 1 of 1

Linux floppy image creation problem

Posted: Thu Jun 16, 2005 2:23 am
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.

Re:Linux floppy image creation problem

Posted: Thu Jun 16, 2005 2:30 am
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.

Re:Linux floppy image creation problem

Posted: Thu Jun 16, 2005 5:17 am
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?

Re:Linux floppy image creation problem

Posted: Thu Jun 16, 2005 5:52 am
by zyp
You have to unmount the image before running bochs.
Bochs reads the image, and not the mounted file system.

Re:Linux floppy image creation problem

Posted: Thu Jun 16, 2005 6:02 am
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. ;)

Re:Linux floppy image creation problem

Posted: Thu Jun 16, 2005 7:29 am
by Curufir
Is there any way to forcely write the changes to the image?
Use the sync command.

Re:Linux floppy image creation problem

Posted: Thu Jun 16, 2005 11:24 pm
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?

Re:Linux floppy image creation problem

Posted: Fri Jun 17, 2005 10:39 am
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.