Page 1 of 1

Handling FDD/HDDs easily

Posted: Sun Jan 10, 2010 4:11 pm
by AUsername
Hello, about 2-3 weeks ago I switched to a new computer, yay! Lots of RAM, space, and raw power. Except for the small little fact that it's an x64 machine.

The problem? It can't run partcopy, debug, VFD, VDK at all. So there goes most of the tools I used to develop an OS. Luckily for me WinImage still worked, at the time I didn't really think of how this would help me since I used WinImage mostly for packaging the beta/final releases of my OS. Turns out that WinImage has as command line interface which allows you to add/delete files and directories to a floppy OR hard drive image.

Since WinImage works with both FAT12 and FAT32, if you're using FAT32 for your HDD filesystem then this method will take the pain out of writing your own tools or using other tools that don't work as well. You just need to write a proper partition.

So if you've switched to an x64 computer and can't work with floppies anymore, or you're looking for a way to easily write files and directories to your hard drive image then this is for you.

Step 1: Get WinImage
This is pretty simple, download WinImage from here (winima85).

Step 2: Install
If I need to tell you how to install something you shouldn't be in OSDev in the first place.

Step 3: Setup your environment
1. Click Start -> Control Panel -> System & Security -> System.
2. In the left side panel click "Advanced System Settings"
3. When the window pops up click the tab labeled "Advanced" and then the button "Environment Variables..."
4. Scroll down the list until you find "PATH", select it and hit "Edit"
5. Append a "C:\Program Files\WinImage\" to the string.

Image

6. Exit everything out and you're ready to continue.

Step 4: Create a floppy image
1. Open up WinImage.
2. Click File -> New.
3. Click the kind of floppy your OS has, or will, be using. I chose 1.44MB.
4. Click File -> Save.
5. Save it in C:\ or somewhere else you feel it's safe, from what I've seen WinImage doesn't like long directories so I put my image here. Name it "floppya.ima".

Image

Note: If you can't save you may need to turn off UAC, or run as admin.

Step 5: Setup the bootsector
1. Click Image -> Boot Sector Properties.
2. You should see a screen like this:

Image

3. Click "Open" and open your boot sector. Since WinImage also shows the OEM name and serial this can be a small way to check if your BPB is aligned properly.
4. Click OK, and save the image.

Step 6: Writing files to the disk
Now that your boot sector is done, it's ready to be written too, assuming the BPB is written properly, so this can also be a little backup that your BPB is correct.

Note: If UAC is turned on then depending on what directory your image is in, WinImage will fail to write to it. For this reason I suggest turning it off, or running it in admin.

1. Open the command prompt and cd to the directory containing the file you're planning on copying, for me this will be my second stage bootloder. Type "winimage <Path to image> <Filename> /I /H /Q".
2. This will copy <Filename> into <Path to image>. "/I" is inject, "/H" is hide the WinImage window, "/Q" is quit after execution (save automatically).

Image
Image

Step 7: Setting up Bochs
1. Open your Bochs configuration file.
2. Append "floppya: 1_44="C:\floppya.ima", status=inserted" somewhere in the file.
3. Save and exit out.

Step 8: Testing
1. Run Bochs
2. ...
3. Profit.

Image

Note: A very annoying message will popup every time you use WinImage to write to the image. Registering professional will fix this.

[Adding directories is a bit trickier the directory will need something in it to be added to the image]
[To be continued]
(I am working on a tool that will make it a bit easier so you don't have to setup environment variables and so on)

Re: Handling FDD/HDDs easily

Posted: Sun Jan 10, 2010 6:08 pm
by ru2aqare
AUsername wrote:Hello, about 2-3 weeks ago I switched to a new computer, yay! Lots of RAM, space, and raw power. Except for the small little fact that it's an x64 machine.

The problem? It can't run partcopy, debug, VFD, VDK at all. So there goes most of the tools I used to develop an OS.
There is a Total Commander add-on that is an x64 port of VFD. It is pretty reliable, unless you forget to unmount the floppy image before hibernating XP (in which case it gets stuck, and cant access your image file until the next reboot). I used RaWrite/RaWriteNT or whatever it was called, and worked just fine (no installation and no administrator rights required). Also most emulators and virtual machine hypervisors have x64 ports now.

Re: Handling FDD/HDDs easily

Posted: Sun Jan 10, 2010 8:02 pm
by ucosty
An alternative that I use to write stuff to floppy images is mtools. They're just command line tools that let you manipulate files in FAT formatted disks and disk images.

Re: Handling FDD/HDDs easily

Posted: Mon Jan 11, 2010 1:52 am
by Combuster
mtools +1. No nagware, can perform about any FAT-related task from the command line, and works perfectly from a build script.

Re: Handling FDD/HDDs easily

Posted: Mon Jan 11, 2010 7:14 am
by Love4Boobies
Oh, awesome! A tutorial on how to use Bochs and WinImage. It even tells us when to click "Ok". It's perfect; you see, I'm an expert programmer but I don't know how to install stuff or set environment variables. </sarcasm>

Re: Handling FDD/HDDs easily

Posted: Mon Jan 11, 2010 10:07 am
by Creature
I've used WinImage myself for a while to adjust floppy images (and have decent 64-bit support), but now I simply switched to CD-images and mkisofs (from CDRTools) which works very well for me.

Re: Handling FDD/HDDs easily

Posted: Mon Jan 11, 2010 10:16 am
by Love4Boobies
I use DAEMON Tools for mounting and InfraRecorder for burning. As for floppy disks, Virtual Floppy Disk and RawWrite for Windows. I find it more productive to use tools with graphical interfaces for things that aren't automated (like building from sources).

Re: Handling FDD/HDDs easily

Posted: Mon Jan 11, 2010 1:54 pm
by Owen
Love4Boobies wrote:Oh, awesome! A tutorial on how to use Bochs and WinImage. It even tells us when to click "Ok". It's perfect; you see, I'm an expert programmer but I don't know how to install stuff or set environment variables. </sarcasm>
Please, if you're going to comment on someone's work, be constructive, or don't comment at all.

Re: Handling FDD/HDDs easily

Posted: Mon Jan 11, 2010 1:57 pm
by Love4Boobies
Owen wrote:
Love4Boobies wrote:Oh, awesome! A tutorial on how to use Bochs and WinImage. It even tells us when to click "Ok". It's perfect; you see, I'm an expert programmer but I don't know how to install stuff or set environment variables. </sarcasm>
Please, if you're going to comment on someone's work, be constructive, or don't comment at all.
I was being constructive by telling the OP that he wasted his time and that the information is useless to everyone here. :wink:

Re: Handling FDD/HDDs easily

Posted: Tue Jan 12, 2010 2:28 am
by qw
Love4Boobies,
At least the AUsername was trying to be constructive. No sarcasm needed.

Re: Handling FDD/HDDs easily

Posted: Tue Jan 12, 2010 2:36 am
by Love4Boobies
Didn't we move on already or are you just trying to start a flame?

Re: Handling FDD/HDDs easily

Posted: Tue Jan 12, 2010 2:41 am
by qw
Love4Boobies,
Relax, will you? I didn't see anybody "move on already". Sarcasm is never constructive, so why not just withdraw your comment and really move on?

Re: Handling FDD/HDDs easily

Posted: Tue Jan 12, 2010 2:49 am
by Love4Boobies
Oh, really? I thought that http://forum.osdev.org/viewtopic.php?f= ... 70#p170437 and http://forum.osdev.org/viewtopic.php?f= ... 71#p170439 were moving on. Perhaps a mod should lock this thread already.