Handling FDD/HDDs easily
Posted: Sun Jan 10, 2010 4:11 pm
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.
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".
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:
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).
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.
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)
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.
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".
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:
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).
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.
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)