LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   VFD & RaWrite equivalents in lunix (https://www.linuxquestions.org/questions/linux-newbie-8/vfd-and-rawrite-equivalents-in-lunix-731400/)

C++arl 06-08-2009 06:30 AM

VFD & RaWrite equivalents in lunix
 
Hi,
I'm really new to linux so bear with me on this one. I enjoy developing a hobby OS which I've done on my Windows computer for a while now, I use vfd to emulate a floppy drive, a self-made version of RaWrite to write .bin files to the virtual floppy and then bochs to emulate a computer running the os from the virtual floppy. I want to do the exact same thing on Ubuntu but havent found neither a equivalent of vfd nor RaWrite, so how can I get the .bin files on to some medium that bochs (atleast I managed to find bochs for linux ) can run from?

So, in short, what i need is:
1. A program that tricks the computer to belive that it has a floppy drive.
2. Aprogram that lets me write data to a given CHS address, on the virtual floppy.

If you got any info/hints on this plz help!

~ C++arl

jamescondron 06-08-2009 10:03 AM

You're falling into the trap of thinking Windows and Linux are the same, or at least operate the same. If you have a floppy image, you can mount it as you'd mount anything (more or less). As for the second, that also already exists (It exists in a better way than RaWrite on Windows, too).

You want to look at the man pages for mount and dd.

i92guboj 06-08-2009 10:19 AM

jamescondron said it all.

In linux the basic tools are files, for everything. Even devices are special types of files.

Any file can be a floppy, you can just create an empty file with dd, use /dev/zero as your if, and any file name as your of, this one will contain your floppy image, you can format the file as you would do with a device like /dev/hda1 with whatever fs you prefer, and mount it in loopback mode (mount -oloop). Once mounted you can put whatever you want into the file. If you already have a working floppy image, just put it wherever you want and instruct bochs to use that file as the boot image. If bochs can't do that, then mount the image file in loopback mode and use the mount point as your floppy drive.

C++arl 06-09-2009 08:00 AM

Thanks for answering,
Well, I've managed to mount a virtual floppy drive,

Code:

# create a image of Zeros of length 2048 bytes
dd if=/dev/zero of=floppy.img bs=1024 count=2048

#make the image of ext2 file system
mkfs.ext2 floppy.img

#create a mount point
mkdir floppy.d

#mount the image to the mount point
mount -o loop floppy.img floppy.d

but this does'nt really solve my problem because in order for my 'os' to work i need to be able to specify exactly where on the floppy to write data to, for instance the boot sector needs to be on CHS 001, furthermore it seems that mount needs you too specify a filesystem for the disk and really don't want that, I just want it too apear as if you've inserted a completely blank floppy.

For writing the boot sector to sector 1 on the emulated floppy i tried this:
Code:

sudo dd if=Programmering/fasm/OS2/bootr.BIN of=/dev/loop0 bs=512 count=1
Also, i'm not sure that the emulated floppy is /dev/loop0 but if I understand mtab right it should be.

i92guboj 06-09-2009 11:25 AM

Quote:

Originally Posted by C++arl (Post 3567884)
Thanks for answering,
Well, I've managed to mount a virtual floppy drive,

Code:

# create a image of Zeros of length 2048 bytes
dd if=/dev/zero of=floppy.img bs=1024 count=2048

#make the image of ext2 file system
mkfs.ext2 floppy.img

#create a mount point
mkdir floppy.d

#mount the image to the mount point
mount -o loop floppy.img floppy.d

but this does'nt really solve my problem because in order for my 'os' to work i need to be able to specify exactly where on the floppy to write data to, for instance the boot sector needs to be on CHS 001, furthermore it seems that mount needs you too specify a filesystem for the disk and really don't want that, I just want it too apear as if you've inserted a completely blank floppy.

True, if you want to write raw to the floppy image just use dd. It can write anything to any offset you want and you don't need to have a mounted disk nor even a fs inside it.

Quote:

For writing the boot sector to sector 1 on the emulated floppy i tried this:
Code:

sudo dd if=Programmering/fasm/OS2/bootr.BIN of=/dev/loop0 bs=512 count=1
Also, i'm not sure that the emulated floppy is /dev/loop0 but if I understand mtab right it should be.
You can just dd straight to the image file, no need to attach it to a loop device, specially if you don't plan to mount it at all (and specially if it's not mountable at all).

C++arl 06-10-2009 05:47 AM

Yea, got it now, I dont even need a emulated floppy drive, I just use dd to write to a img file and then tell bochs too boot from that file. Thx all!


All times are GMT -5. The time now is 09:39 AM.