drives

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Subject: Re: low level format query
From: Ramon Gandia <rfg@nook.net>
Date: Thu, 29 Apr 1999 02:02:09 -0800


A lot of confusion as to what low level and high level formats
are.  Here goes the explanation.

A disk is laid out in tracks.  Each track has (nowadays) sectors
of 512 bytes each.  There are several sectors in a track.   Between
the sectors are the gaps.  The gaps are not empty but are filled
with a certain byte pattern.  Within this gap are also index
marks (marks one spot on the track so the computer can tell
when the disk has gone one revolution).  There are also sector
id's, called address marks.

A low level format writes out the whole track.  It puts
down the gaps, the index mark, the sector id's and the filler
bytes for the sectors, usually E5.

A high level format merely rewrites E5 to the sector data
(the 512 bytes) and leaves the gaps, index and address marks
alone.  When you write E5 to all the data sectors, any 
FATs, directories, inode tables, boot sectors and the like get
overwritten with the E5 filler bytes.

Microsoft has a "quick format" for floppies that high-level
formats just the tracks containing the boot, FAT and directory
sectors.  Since the other tracks are not touched, it is fast.
The problem is that the disk is not checked for integrity.

Checks are done by read-after-write, so when E5's are written,
they are verified.  Some format programs do it on the fly, some
write the whole disk then verify it.

On older hard drives, MFM type, the typical mechanism was a
stepper motor driving a lead screw.  The lead screw mounted
the drive head and when the motor rotated so many degrees, the
screw would turn so much and the head would move in or out a
predetermined amount.  The drive was formatted track by track.
After some use, the mechanism was worn down some, and the
same rotation of the motor would not bring the head centered
on the track, but skewed to one side.  Data from the other
track would bleed over, and the disk would start getting errors.

At this time, the disk was low level formatted again, and the
result was a new set of tracks centered on where the mechanism
wanted to be.  More wear would require another low level format.
After a while the drive would get sloppy and erratic and it
had to be junked.

The mechanism was slow since it was heavy and ponderous.

Along came IDE drives and about the same time they started using
"voice coil" mechanism.  These had an electromagnet that would
move the head in and out over the platter.  Unlike the stepper
motor that could predict where the head would fall, the voice
coil cannot predict its location.  Thus one entire platter is
devoted to servo tracks.  A servo track is a track that has
information on it, indicating the track number.  The IDE
controller moves the voice coil a bit and reads the track
number from the servo track.  It then goes in or out some more
until its on the right spot.  The servo track has special
writing on it and lets the head stay centered on the track.
If the head drifts out, the servo head can sense this and
return back on track.  All the other platters have their
read-write heads ganged along with the servo head so it all
tracks together.

In a mechanism of this type, the servo tracks are special and
are manufactured into the drive.  The data surfaces on the
other platters are low level formatted.  

Since there is no drift, there is never any need to low level
format a modern drive unless something ruined the track.  The
chief reason for this is head crashes which scrape the coating
off the drive.  For this reason, a drive that needs a low level
format is usually a bad drive.

IDE and SCSI drives have built in controllers.  Some have
commands to low level format them.  Some do not.  Those that
do not are bulk formatted at the factory with special controllers.
The mechanism is connected to the formatter and formatted.  The
drive goes down the assembly line and is mated with the controller
board.  Thus the controller board does not have the low-level
format commands.  This is the usual arrangement nowadays.

In any case, there is no standard low-level format command
any more.  They are proprietary to the drive manufacturer.  On
those drives that have it, it usually requires that you put
a jumper in place and do the low level format.   This will
require an assembly language program, or at least some method
of getting commands and results in and out of the disk.  These
are not trivial programs.

A lot of hot air goes around about "low level formats" but on
modern drives you will find it very hard to find one that can
be low level formatted.  Issuing commands meant for older
jackscrew/motor type of drives to a modern IDE or SCSI drive
will result in unpredictable action, which may be harmful to
the drive.

At the present stage of prices for drives,just pennies per
megabyte compared with thousands of dollars per megabyte just
fifteen years ago, there is very little to gain with attempting
a low level format.  On the old 5 MB drives of 1976 you could
fill the drive in a couple of weeks -- or even a day.  By
the same token the data could be backed up to two or four
8" floppies in a few minutes.  It was easy to backup, and
if you lost a drive, it was no big deal.  Hard drives were used
because of their speed, not because of their large capacity.

Today, with gigabyte drives, backups are seldom done.  They
take months to fill up,a nd when one of these drives goes bad
it is usually a serious disaster that takes a lot of data with
it.  Therefore, drives that are marginal are best replaced.
If you get messages about index or address marks not found, or
Seek Errors, or Interrupts....it means the drive is going bad
and needs to be backed up NOW....preferably before another
reboot.  After you get all you can out of it, the drive is
replaced.  Anything else is folly.

The commands to format in MSDOS is:

floppy:  Low Level and high-level formats are combined in
the FORMAT.COM program.

C:\> format a:    (will low and high level format drive A:)

hard drive is strictly a high-level format:

A:\> format c:   (high level formats hard drive C:)

In Linux, the two commands are separate.  The low level
format lays down the track by track gaps and blank sectors.
The high level format lays down the filesystem info and inodes:

floppy format, low level, for a 1.44 mb disk and associated
mkefs for high-level format:

Prompt# fdformat /dev/fd0H1440
prompt# mke2fs -c /dev/fd0  1440

For a hard drive, only the high level is used.

Data partitions: prompt# mke2fs -c /dev/hdb3
Swap partitions: prompt# mkswap -c /dev/hdb4

The -c verifies after writing form both hard and floppies.

In the Altair days I wrote several BIOSes for CP/M including
floppy and hard drive formatters.  Lots of fun, all in assembly
language.

========


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu