PDA

View Full Version : Creating bootable DOS hard drive images under Linux



eeguru
March 26th, 2017, 09:51 PM
Before I dive down the rabbit hole, I figured I would ask for thoughts first.

I'm trying to create, in Linux, an arbitrarily sized hard drive image file based on a supplied CHS. I've already created a partition table that matches and spans the given geometry and made the lone primary partition active. If I extract the first sector of an existing SYS'd hard drive image for any given MSDOS version - minus the partition table, IO.SYS, MSDOS.SYS, and COMMAND.COM, is there a convent way of moving those to a new image - in Linux?

Is it sufficient to mkdosfs the partition, update the first sector with the trimmed MBR, copy IO.SYS, MSDOS.SYS, and COMMAND.COM in that order and ensure the HIDDEN and SYSTEM attributes are set on the first two files?

Does SYS.COM do anything different or beyond that? And does any other package (eg FreeDOS, etc) provide an equivalent to SYS.COM for a POSIX OS?

Thanks, -Alan

PS. At a block access level, I see SYS.COM in PCDOS 5.01 writing to a bunch of sectors beyond what I expect... like it's creating tables or something. This is what has me doubting whether it is as simple as it seems.

alecv
March 27th, 2017, 05:45 AM
You could use PCem emulator with your HDD image. For "XT clone" configuration PCem uses XT IDE Universal BIOS and emulates XT-IDE v1 hardware.
Disable IDE geometry auto-configuration with XTIDECFG, setup C/H/S manually for your image and copy new XUB into PCem directory.

lowen
March 27th, 2017, 12:22 PM
... If I extract the first sector of an existing SYS'd hard drive image for any given MSDOS version - minus the partition table, IO.SYS, MSDOS.SYS, and COMMAND.COM, is there a convent way of moving those to a new image - in Linux?...
The mtools package, included with many distributions, is probably what you're looking for.

eeguru
March 27th, 2017, 01:21 PM
I believe I've worked out the details. I've captured the MBR boot code and the boot sector at the start of the DOS partition for a small menagerie of MS-DOS and PC-DOS versions. Today I observed what most of those versions of DOS actually do when partitioning, formatting, and transferring the boot code.

It seems things are as I expected other than placing the boot sector code in the first reserved sector of the DOS file system image. Thanks for the feedback.

To quote Dave Bowman, I'm working on 'Something Wonderful'...

Trixter
March 27th, 2017, 03:46 PM
Will it dream?

eeguru
March 27th, 2017, 04:05 PM
Yes.. and it's causing me to age as radically as him!

Malvineous
April 2nd, 2017, 01:59 PM
I've done this before by creating an empty file of the correct size, then mounting it in DOSBox as a raw disk image, supplying the CHS values to DOSBox. I have then booted DOS install floppies in DOSBox and installed DOS onto this disk image, and the whole process worked quite well. I have then taken this file and used "dd" to move it onto an SD card and it successfully booted on a real machine.

The hardest part was figuring out the correct CHS mapping for the size I wanted, ensuring it matched the CHS -> LBA conversion algorithm used by the destination machine. Some of my early 486 machines used a different CHS algorithm rather than the later standard which caused me a bit of trouble.