Reading old disks on Linux

From: Fred Cisin <cisin_at_xenosoft.com>
Date: Wed Oct 16 19:00:01 2002

> > It has some good information, some errors, and some good and bad guesses
> > (such as saying that it is probably possible to read hard sectored disks
> > with PC hardware)

On Wed, 16 Oct 2002, Patrick Finnegan wrote:
> If you're refering to 'fixed format devices', they seem to be referring to
> OS device nodes - such as "/dev/fd0h360", not physical (hard-sectored)
> devices/disks.

NO. For example,
In "Interesting Formats", (as quoted in the next paragraph) they seem to
be implying that the original PC diskettes are FM (not MFM), which is
FALSE.
Then they list "CP/M, Apple II, TRS-80, etc."
Then they explicitly mention hard sectored, with the wrong guess that they
would be readable on standard FDCs.
Then they say that the 160K/180K formats were double sided; which is
WRONG.

> 80/90/160/180 KB 5.25"
> Original IBM PC, CP/M, Apple II, TRS-80, etc. Single density, FM (not
> MFM), 40-track. Some systems also used "hard" sectoring, with an index
> hole for each sector. These are probably readable on standard FDCs if
> anyone cares to go to the effort. 160KB/180KB formats were double-sided.

There are numerous such errors on that page, although overall the content
is good.


> To me, it looks like the hardest part will be attempting to determine what
> format the disk is in, automatically. Any ideas? My best guess is to do
> a guess-and-check method, of course this would be tough to verify every
> possibility, such as varied sector sizes (although it would be possible).
> I'm guessing that I'll have to use a raw floppy ioctl to make that work.

Fully automatic determination is NOT possible. But you CAN eliminate most
other possibilities, and reduce it to something that can probably handle
all of the different formats that you have. SOME parameters, such as
sector sequence (aka interleave) are trivial to determine manually, but
hell to do automatically. Likewise, but actually a little easier, "which
track has the DIRectory?"

In XenoCopy, I put in a partially documented "feature" that would look at
a disk, and then gray-out formats from the menu (of 400 machines) that had
different physical characteristics.


If you are willing to program the FDC directly, you can try to read the
sector headers.
If you are NOT willing to go down to that level, then:
1) try to read, oh say, 512 byte sector #1 Track #4, from track 4, side A,
        if you get an error code 2 ("Address mark not found") from the
        BIOS, then you have the wrong density, or recording method
        If you get error code 4 ("sector not found"), then you have the
        right density, but wrong sector size, wrong track density, or
        weird numbering (not that uncommon)
                If you can read sector #1 Track #8 from track 4, then you
                are trying to read a 96TPI disk in a 48TPI drive or mode
                Try 256 and 1024 bytes per sector. (128 has some bizarre
                problems of its own)
        Once you finally get a sector to read, increm,ent the numbers to
        find how many sectors per track.
2) Once you know the bytes per sector, and sectors per track, then try
reading from side B. Since side A and side B are normally the same
density (except on track 0 and occasionally a few more), an error code of
2 would mean that the disk is single sided.
        some formats, such as Kaypro DS use an incorrect value in the side
        number field of the sector headers on the second side. It isn't
        that hard to program around, but watch out for it.
3) confirm the maximum track (usually 40 and 80, but sometimes 35 and 77!
4) once you have determined the physical format, you can duplicate disks,
but not retrieve data from them in a reliable way until you determine the
logical parameters:
        a) side pattern: some formats go up one side and then up the
        second side (common when expanding a SS format to DS). some go up
        the first side and then DOWN the second side (performance
        improvement in "expanded formats") Some (including MS-DOS) use
        both heads of a cylinder before incrementing the cylinder
        b) DIRectory location: MS-DOS (with a few great exceptions) puts
        the DIR on track 0; CP/M puts it a few tracks in (after reserved
        tracks (which MAY be a different format!!); some formats, such as
        "stand-alone BASIC" (Coco, etc.) try to put it half way (track 17, 20,
        etc.)
        c) DIR structure (what OS?)
        d) DIR parameters (how many blocks for the DIR, block size,
        number of bytes used to represent a block number (such as if
        the number of blocks is > 255)
        e) sector interleave (what sequence are the sectors in?

BUT, ...
whatever you do, somebody can screw it up! For example, some formats use
8 sectors per track, but FORMAT 9!
Sometimes somebody takes a previously used DS disk, and reformats, and
uses a SS format on it. The extraneous stuff on side B can completely
confuse an automatic selection algorithm.


I estimate that there are about 2500 mutually incompatible floppy disk
formats. I've analyzed about a quarter of them, and implemented about 2/3
of those.


--
Fred Cisin                      cisin_at_xenosoft.com
XenoSoft                        http://www.xenosoft.com
Received on Wed Oct 16 2002 - 19:00:01 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:35:33 BST