Pregunta

I was playing around with an OS-development tutorial here. However, as it is based on Windows as the development platform, I was wondering if there is an equivalent software (or some way) to have a virtual floppy drive.

¿Fue útil?

Solución

The virtual floppy drive only seems to be used in that tutorial in order to create a virtual disk that Bochs can boot off of. Linux is actually more flexible in this regard. What you'll need to use is a loop device. How to use this with Bochs, I don't know - you'll need to read the documentation :)

Otros consejos

There is a far too common misconception that simply mounting an image will magically emulate hardware. Mounting a filesystem image with the mount command in Linux merely has the files in that image displayed in the directory which you mount it to. No emulation of a floppy drive. I do not know of any floppy emulator for Linux. Please read this thread, especially my post, currently at the end of the thread, explaining simply mounting vs. emulation: http://forum.osdev.org/viewtopic.php?f=1&t=21589 .

Note that QEMU, Bochs, and VirtualBox really do emulate a floppy drive to the virtual machine. That is hyperviser-level emulation of hardware. I do not know of any kernel-level emulation of a floppy drive for Linux.

But chances are you can accomplish what you want to do with dd, wxHex, the mount command, and some virtualization and/or machine emulation software, such as QEMU, Bochs, or VirtualBox.

Imaging floppy example (some commands may need root privileges, prepend with "sudo" or drop to a root shell via "su" for root privileges):

dd if=/dev/floppy0 of=$HOME/images/my_floppy_image

then do:

openssl md5 $HOME/images/my_floppy_image

to get the md5 hash of the image, then image again to a second file:

dd if=/dev/floppy0 of=$HOME/images/my_floppy_image2

Hash the second image, and make sure they match.

You can open your image with wxHex for hex editing. If you run wxHex as root, it can even open and edit through the hardware abstraction file, going right to the floppy disk (open /dev/floppy0 or whatever).

Mount the image via a loopback device:

sudo mount -o loop $HOME/images/my_floppy_image /media/floppy

The first sector (first 512 bytes) of the floppy diskette or image is the VBR (volume boot record), and should include the bootloader. Since this is technically a part of the filesystem, you can access this from a loopback device, which only mounts filesystems. If you instead mounted, via a loopback device, a partition within a hard disk image, and the bootloader was in the MBR (outside of the filesystem of the mounted partition), the bootloader would not be accessible from the loopback device, which, again, only mounts a single filesystem.

Getting the VBR only:

dd if=/dev/floopy0 of=$HOME/images/my_floppy_VBR bs=512 count=1

Of course you can reverse any of the dd things to go from image to a floppy diskette or other image.

blow image onto floppy:

dd if=$HOME/images/my_floppy_image of=/dev/floppy0

blow only the VBR onto a floppy:

dd if=$HOME/images/my_floppy_VBR of=/dev/floppy0 bs=512 count=1

Or if the above blows over things you don't want blown over, maybe something like this:

dd if=$HOME/images/my_floppy_VBR of=/dev/floppy0 bs=440 count=1

Just do whatever you have to do.

Get VBR out of an image:

dd if=$HOME/images/my_floppy_image of=$HOME/images/my_floppy_VBR bs=512 count=1

Getting the first 440 bytes from an image:

dd if=$HOME/images/my_floppy_image of=$HOME/images/my_floppy_first_440 bs=440 count=1

From the above examples you should be able to figure out how to blow just the VBR or just the first 440 bytes from a given source (floppy or image) onto an image, editing the image. "if" stands for "input file" and "of" stands for "output file". Remember that even a real floppy diskette (as opposed to an image) is referred to by a file (like /dev/floppy0). Yes, /dev/floppy0 is actually a file that you can navigate to and see in the file browser. It is an abstraction file created by the kernel used to talk to the actual floppy drive.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top