Classic Computer Magazine Archive START VOL. 3 NO. 5 / DECEMBER 1988


START'S SPECIAL HARD DRIVE SECTION




Small Tools

Hard Disk Lore and First Aid Part I

by David Small


We've all been there. Last night your hard disk was working fine. There were "4,567,000 bytes used in 210 items", not to mention the fifty folders on it--a full 10 megabytes of data!

Today, you turned your ST on, the hard disk hiccupped briefly and then you saw: "0 bytes in 0 items". Your data was completely gone.

Welcome to the club.


Screaming Into the Night

Hard disks are fast and store a great deal of data, but if you make a mistake (or the ST makes a mistake) on a single floppy, then you've lost perhaps 720K of data (double-sided disk, that is). If you lose a hard disk, however, you may have lost 25 times more data.

Dan Moore and I grew so experienced at troubleshooting hard disk problems during our days at Data Pacific that they became relatively routine. Of course, we learned in the hardest possible way. Thousands of lines of code and days of work were eaten during various hard disk crashes. Hard disks would fail in amazingly creative ways, thus disproving the idea that machines are not (maliciously) intelligent.

harddisklore.jpg
This Seagate 225 is a very typical hard disk. The ST's operat-
ing system and hardware must translate your request to open a
file into electrical signals that properly position the read/write
heads on the platters.

Over time, we accumulated a number of tools and techniques for reviving hard disks and preventing the worst of possible damage: complete loss of data. We've published a number of these techniques in START: for example, the hard disk Reviver program (in the Spring 1987 issue), and the Meg-a-Minute Elite Hard Disk Backup program last issue.

It gradually dawned on me that START's readers might appreciate learning the easy way what Dan and I had to learn the hard way. That's what this column is about. In later installments, we'll present some of the tools and fixes we developed. Of course, don't expect to learn everything from this one article. If you want to "get your hands dirty" and tear into your hard disk--hardware, software or both--you're going to have to do more specialized digging. Right now, let's review some disk basics.


Disk Basics

Most people don't really understand how the ST's disk drive system works. That's because Atari has tried very hard to shield you from what really happens on a disk when you're using it. They tried for an "intuitive" user interface that would seem logical and easy for people to use but that doesn't mean it's intuitive or logical to the ST! So let's look quickly at an average disk system.

A 360K (single-sided) floppy disk has 720 "sectors" on it. Each sector has exactly 512 bytes in it (1/2K). There are 80 circular "tracks" on the floppy, each track pie-sliced into nine 512-byte "sectors." Nine sectors per track times 80 tracks equals 720 total sectors.

A double-sided floppy disk has 1440 sectors on it; each side has the same layout as a single-sided drive. Thus, two sides times 720 sectors equals 1440 total sectors.

To read or write a sector, the "head" is moved, or "stepped," in or out to one of those 80 tracks. Then the disk spins and the head waits for the correct sector to spin by underneath it; it is at that point that the data transfer actually takes place. It takes about .016 second to read or write one sector on a floppy disk.


Nice, Round Chunks of Data

Everything that happens to your disk drive happens in nice, round 512-byte chunks, or sectors. When you read a sector, you always read 512 bytes; when you write a sector, you always write 512 bytes. If you don't need all 512 bytes, the remaining bytes are just wasted.

Now, most of the disk area is purely for file storage. A little of it is devoted to the Directory, which tells the ST where files are located on the disk and the File Allocation Table (FAT), which tells the ST which sectors on the disk are used.

Atari's Graphics Environment Manager--Disk Operating System (GEMDOS) handles all the disk drives attached to your ST. The GEMDOS takes all of your disk "file operations" requests--making a new file, saving it, renaming it, deleting it, moving it--and translates them into 512-byte sector read/write requests to send to your disk drive. Your disk drive knows nothing about "files"; all it knows how to do is read or write a given 512-byte sector (and how to format a disk).

For illustration's sake, let's say sectors #2-10 are the directory, #11-20 are the FAT and sectors for storing files begin at #21. (This is just for illustration; don't use this in real life!)

Let's say that your program TEST.PRG is 100K long, so that it uses up 200 sectors of storage. To find and start up TEST, the ST looks through the "directory" (sectors 2-10), finds where TEST is stored (for example, sectors 550-749) and reads sectors 550-749 into memory. Then the ST will begin to execute the code it read in. This is what really happens at the lowest level.

What I want to stress is the idea that even with odd-length files you request, even with all the folders and windows and icons, there are still only three things that are ever done by a disk drive:

  • Read sectors, all of which are 512 bytes long;

  • Write sectors, all of which are 512 bytes long; and

  • (less common) Format a disk.

If you want more details than this about floppy drives (and formatting), please see "Probing the Floppy Disk Controller" in Issue #2 of START. (Editor's note: This issue is sold out, but if you send a self-addressed stamped envelope and $1 to Floppy Disk, START Reprints, 544 Second Street, San Francisco, CA 94107, we'll send you a photocopy of that article.)


Hard Disk Basics

A hard disk is also composed of 512 byte sectors, but many more than a floppy disk. A 10-megabyte (Mb) hard disk has 20,000 sectors, a 20-Mb hard disk has 40,000 sectors and so on. Again, a small portion of the hard disk is reserved for the FAT and Directory and the rest is available for storage.

Hard disks have a few things going for them over floppies. The first is that they spin at 3600 RPM, instead of a floppy's 300 RPM. This means the single biggest cause of a floppy's slow speed, "rotational delay," is reduced more than 10 times on a hard disk. On a hard disk, it takes only .0013 second to read in a sector, 12 times faster than on a floppy.

There are more subtle considerations as well. A typical 20-Mb unit has 615 tracks with 17 sectors per track--but there are also two "platters" within that hard disk with one head on each surface (top and bottom). Yes, there are four read/write heads! Because of this design, the hard disk can access 68 sectors of data without even having to move the heads.

On computers other than the ST, the hard disk can feed data into the computer so fast the computer gets confused. Therefore, the sectors must be numbered strangely, or "interleaved," to slow down the data transfer rate! This is very common on the IBM PC, where a 4:1 slowdown is often needed.

The ST is a different breed, however. It has a dedicated "DMA" or "Direct Memory Access" chip. The DMA chip is designed to briefly take over memory from the CPU chip. This is significant because it enables the full power of the ST to be dedicated briefly to the hard disk and means that the hard disk can be run at 1:1 interleave. Remember, all we are doing is transferring 512-byte sector chunks to or from memory; if we can have uninterrupted access to the memory (which the DMA chip gives us), we can use the disk drive at its fastest rate.

No one has ever accused the ST of being a performance slouch; the DMA chip is one reason.


Average Access Times

Let me introduce you to another buzz-word and give you some feel for what it means. It's called "average access time." Once you can run a hard disk at 1:1 interleave, the determining factor of how fast a hard disk is becomes how quickly it can move its head from track to track. There's an industry standard called "average access time," which tells you how long it takes to get from one track to another on the average (not from one track to the next track, just some track to some other track). This time is expressed in milliseconds.

To give you some common timings, the slowest I've seen is 105 msec access time on a Microscience 20-Mb drive. Atari often uses a Seagate ST-225 mechanism, possibly the most popular 20Mb drive unit in the world, with a 65 millisecond average access time. This is medium speed. Faster mechanisms (sometimes called "AT Class" disk drives) are in the 20-30 millisecond range. The very hot 80386 or 68030 machines are using hard discs with under 10 millisecond access times; this is very, very fast and the drives are very, very expensive.

So, we have 40,000 sectors (20 megabytes) on our hard disk. What do we do with it all? Let's leave that for our next installment. . .

David Small is the creator of the Magic Sac Macintosh emulator, and has just released Spectre 128, a Mac Plus and Mac SE emulator for the ST.