create a virtual floppy image without mount?
Yes, of course you can do this. Use mtools
for the FAT and e2tools
or genext2fs
for the ext2 filesystems.
$ dd if=/dev/zero of=/tmp/disk1.img count=1440 bs=1k
1440+0 records in
1440+0 records out
1474560 bytes (1.5 MB) copied, 0.00569719 s, 259 MB/s
$ /sbin/mkfs.msdos /tmp/disk1.img
mkfs.msdos 3.0.12 (29 Oct 2011)
$ mdir -i /tmp/disk1.img
Volume in drive : has no label
Volume Serial Number is 9913-BFF6
Directory for ::/
No files
1 457 664 bytes free
$ mcopy -i /tmp/disk1.img /etc/issue.net ::/
$ mdir -i /tmp/disk1.img
Volume in drive : has no label
Volume Serial Number is 9913-BFF6
Directory for ::/
issue net 28 2012-06-26 10:49
1 file 28 bytes
1 457 152 bytes free
And of course, I have no root rights.
RAW write to a vhd without mounting
For a "fixed" VHD you could, as you said : "just take a textfile or another file an write the bytes in it exactly to a disk." Fixed VHDs are just flat disk images plus a 512 footer at the end. As long you don't touch this trailing footer the raw block level edits (manual or programmatic) should be fine.
For dynamic VHDs or any other sparse representation of a physical disk, the task boils down to translating logical disk offsets into the "container" file offsets. Specifically, for dynamic VHDs, the entire length of the physical disk is divided into logical 2MB windows. The dynamic VHD representation of this physical disk is essentially a sequence of such 2MB blocks, in no particular order. Meaning: In dynamic VHD image, a 2MB (physical) disk window could potentially reside (in the dynamic VHD) after a 2MB disk window which in the actual disk would always be physically before the first 2 MB window. The mapping of which VHD block corresponds to which physical disk window is maintained in the Block Allocation Table. BAT entries (unlike how data blocks are potentially positioned non-sequentially) are ordered and contain the dynamic VHD file offset of the corresponding container data block.
So all we have to do is: find the "VHD file offset" of the logical block which we need to write to using the entry for the 2MB logical window present in the BAT. Then, add 512 to it (i.e. skip the sector bitmap which precedes every block). The VHD file offset which you get at this point is the offset where you need to write to given the input, logical disk offset. It is quite possible that the BAT does not have an entry for the logical disk block that you need to write to. In such scenario, you need to append a new [512 Bytes + 2MB] data block to the dynamic VHD, update the BAT entry to point to the start of this block (the 512 sector) and then update the dynamic header and footer's CRC field since we have updated the BAT (CRC is over it). Please bear in mind that this scheme is valid only for dynamic VHDs which are not linked. Meaning, if there's a linked differencing child VHD then we should apply the above process on the child and not the base. The relationship on who's the parent and who's the child are again present in the dynamic VHD's header. Writing to the child additionally requires updating the 512 byte sector bitmap.
Every virtualized image container has similar schemes to represent disk blocks in a sparse fashion. If we go through the format then reading and writing (at block level) is possible. Furthermore, for most cases we could, in principle, do granular volume level reads by translating volume level offsets to disk level and then running the above look-ups
Virtual Floppy drive in Linux
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 :)
Related Topics
Capture Both Exit Status and Output from a System Call in R
How to Set Environment Variables on Ec2 Instance via User Data
Numa Aware Cache Aligned Memory Allocation
How to See Contents of Hive Orc Files in Linux
Gdb Can Not Open Shared Object File
Linker Error on Linux: "Undefined Reference To"
Importerror: No Module Named Matplotlib with Matplotlib Installed
What Character Sequence Should I Not Allow in a Filename
How to Change the Mime Type of a File from the Terminal
Linux Command Output as a Parameter of Another Command
How to Do Foreach *.Mp3 File Recursively in a Bash Script
Decrypt Obfuscated Perl Script
Can't Read Variable That Was Stored from Within a While Loop, When Out of the While Loop