   Fdutils Copyright (C) 1993-2000 Alain Knaff

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Free Software Foundation.

Introduction
************

   Fdutils is a collection of utililties for configuring and using the
Linux floppy driver.  With fdutils, you can:

  1. Format disks with a higher capacity than usual (up to 1992KB on a
     3 1/2 HD disk).

  2. Reconfigure the autodetection sequence to automatically detect
     some of these extended formats.

  3. Access various internal driver structures and drive configuration
     using the floppycontrol program.

   This manual describes these utilities, and also the floppy driver
itself.

Where to get fdutils and its documentation
******************************************

   Fdutils can be found at the following places (+ mirrors):
     ftp://www.tux.org/pub/knaff/fdutils/fdutils-5.4.tar.gz
     ftp://metalab.unc.edu/pub/Linux/utils/disk-management/fdutils-5.4.tar.gz
     ftp://tsx-11.mit.edu/pub/linux/sources/sbin/fdutils-5.4.tar.gz

   The FAQ included in this package is also available separetely at:
     http://alain.knaff.linux.lu/floppy/FAQ.html
     http://www.tux.org/pub/knaff/floppy/FAQ.html
   The FAQ at fdutils.linux.lu and www.tux.org is usually more up to
date than versions found elsewhere.  Thus, if you don't find an answer
in the copy of the FAQ you have, please check this one for more recent
info.

   Before reporting a bug, make sure that it has not yet been fixed in
the Alpha patches which can be found at:
     http://fdutils.linux.lu
     ftp://www.tux.org/pub/knaff/fdutils

   These patches are named `fdutils-'VERSION`-'DDMM`.taz', where version
stands for the base version, DD for the day and MM for the month. Due
to a lack of space, I usually leave only the most recent patch.

   There is an fdutils mailing list at fdutils @ www.tux.org .  Please
send all bug reports to this list.  You may subscribe to the list by
sending a message with 'subscribe fdutils @ www.tux.org' in its body to
majordomo @ www.tux.org . (N.B. Please remove the spaces around the "@"
both times. I left them there in order to fool spambots.)
Announcements of new fdutils versions will also be sent to the list, in
addition to the linux announce newsgroups.  The mailing list is
archived at http://www.tux.org/hypermail/fdutils/latest

Basic usage
***********

   This chapter describes basic usage of floppies, and gives a few
simple tips for using floppies under Linux.

How disks are organized
=======================

   All floppies have two levels of _formatting_, both of which must be
known in order to read them.  The first is the _binary_ or _sector_
level format, which is how raw data is stored on the disk.  The second
is a higher level organization, often called a _file system_, which
allows multiple files to be conveniently stored on the disk.

   For example, a typical 1.44MB disk contains a low-level format, with
18 sectors per track, 80 tracks, and two sides (or heads); each sector
can hold 512 bytes of data for a total of 1474560 bytes (or 1440 KB).
When used under MS-DOS, this floppy would have a small portion of the
disk used to keep track of files on the disk (including a bootsector,
file allocation tables, directories, etc.).

   The floppy driver generally takes care of reading the binary, or
low-level format.  It can often "guess" the low-level disk geometry
needed to read the disk.  This is called autodetection (see
Autodetection).  If the driver can't autodetect the disk (e.g. if it
is in an unusual format) you can tell the driver what the geometry is
either by using the `setfdprm' (see setfdprm) utility or by using a
fixed geometry device device (e.g. `/dev/fd0H1440').

   Under Linux, many different file systems from many sources can be
used.  Some of these file systems are interpreted via a utility program
(for example `mtools' for using disks with an MS-DOS file system).  Many
file systems can alternatively be "mounted" to appear in the UNIX
directory structure until subsequently being unmounted; this is usually
implemented by having the kernel itself interpret the file system on the
disk.

File systems supported by Linux
===============================

   The following file systems are supported:

*OS/2 HPFS:*
     read-only support (mount/kernel)

*Mac HPFS 1.44MB:*
     read-only (xhfs utility)

*MS-DOS:*
     read, write, format (mtools utility _and_ mount/kernel)

*tar, cpio:*
     compatible with many variations of UNIX (tar, cpio utilities)

*System V, minix, xia, ext, ext2:*
     (mount/kernel)

*pure binary disk access:*
     no file system (any program, usually dd, cat, and cp)

What's in a name
================

   The following figure shows the meaning of the different parts of the
name of a floppy device:

      +--------------- /dev: directory for devices
      |   +------------- fd: floppy disk device prefix
      |   | +------------ 0: floppy drive #0 (A:) (0-1 typical, 0-7
      |   | |                possible)
      |   | |+-- 3.5" drive: (use d for 5.25" double density drives, and
      |   | ||                    h for 5.25" high density drives,
      |   | ||                    u for 3.5" drive of any density)
      |   | ||   +---- 1440: Capacity (in KB) of format (usually between
      |   | ||   |           360 and 3920)
     /dev/fd0u1440

What to do if you get an unidentified floppy disk
=================================================

     dd if=/dev/fd0 of=/tmp/foo count=1
             # If it works:
     getfdprm                # This will report what geometry the disk has
     file /tmp/foo           # This may indicate the type of file system
     mdir a:                 # Check for an MS-DOS file system
     tar tvf /dev/fd0        # Check for a tar archive
     cpio -itv < /dev/fd0    # Check for a cpio archive
     e2fsck /dev/fd0         # Check for an "ext2" file system
             # If it doesn't work:
             # Try the above dd command using various /dev/fd0* devices

Nickel tours
============

mtools
------

     mdir a:                # Read directory of MS-DOS disk in drive A:
     mcopy /tmp/foo\* a:    # Copy files beginning with foo in /tmp to A:
     mcopy a:\* .           # Copy all files from A: to current directory
     mformat a:             # Add MS-DOS file system to formatted disk

Tar (Tape ARchive)
------------------

     tar tvf /dev/fd0              # Read directory of tar archive in
                                   # drive A:
     tar cvf /dev/fd0 foo1 foo2    # Write foo1 and foo2 to A: in tar
                                   # format foo1/foo2 can be entire
                                   # directory trees
     tar xvfp /dev/fd0             # extract entire tar archive in
                                   # drive A:

   Tar is not a file system.  Only low-level format (`superformat',
see superformat) are needed to prepare a disk to accept a tar
archive.

CPIO (CoPy In/Out)
------------------

     cpio -itv < /dev/fd0        # Read directory of cpio archive in A:
     find foo1 foo2 -print | cpio -ov < /dev/fd0
                                 # Write foo1/foo2 to A:
                                 # foo1/foo2 can be entire directory trees
     cpio -idumv < /dev/fd0      # extract entire CPIO archive in drive A:

   Note: blocks reported are in 512-byte units (due to UNIX System V
heritage).  Cpio is not a file system.  Only low-level format (fdformat
or superformat (see superformat) needed.

Ext2 (Second Extended File System)
==================================

     mke2fs /dev/fd0 1440          # Makes an ext2 filesystem of 1440
                                   # block on A:
     mke2fs -c /dev/fd0 1440       # Same as above, but tests floppy first
     e2fsck /dev/fd0               # Tests filesystem integrity. (like
                                   # chkdsk in Dos)
     e2fsck -p /dev/fd0            # Repairs filesystem. (like chkdsk /f
                                   # in Dos)
     mount -t ext2 /dev/fd0 /mnt   # Mounts the disk in A: on /mnt.
                                   # The directory /mnt must already exist
     umount /mnt                   # Unmounts /mnt. No process should
                                   # have its working directory in /mnt
                                   # No process should have open files in
                                   # /mnt

   Note: don't use ext2 on 2m disks On some systems `mke2fs' is also
called mkfs.ext2, and e2fsck is also called fsck.ext2

New Features of 1.2+ kernels
============================

New features of 1.2+ kernels
----------------------------

   * Faster and more comprehensive automatic sensing of floppy formats

   * Second Floppy Disk Controller (FDC) supported

   * DOS fdformat-style formats (up to 21 sectors on HD 3.5" disk)

   * DOS 2m-style formats (up to 24 sectors equivalent on HD 3.5" disk)

   * non-DOS 2m-inspired formats

   * Several long-standing bugs fixed

   * More exact detection of FDC type

   * More exact detection of floppy drives

New features of mtools-3.0
--------------------------

   * Support for new floppy formats (fdformat, 2m, 2m-like, ED)

   * 2.88MB (Extra Density) floppies supported

   * More friendly syntax (e.g. "mcopy a:", "mmove")

   * Improved mmount

   * 16-bit FATs (needed for some ED formats)

   * Automatically sets disk geometry for Linux

   * Several bug fixes

   NOTE: Mtools has no longer maintained by its original maintainer
Emmet P. Gray after 2.0.7.

New Utilities
-------------

   * `superformat' (replaces fdformat; up to 3.84 MB floppies, faster,
     calls mformat)

   * new `getfdprm'/`setfdprm'

   * `fdrawcmd' (allows user-mode programs to do low-level floppy
     actions) `floppycontrol' (general-purpose floppy driver
     configuration utility)

   * `MAKEFLOPPIES' (makes floppy devices)

Device numbers
**************

   The floppy device nodes are usually made using the `MAKEFLOPPIES'
shell script (see makefloppies.).

   The major device number for the floppy drives is 2.  The minor device
number contains describes which drive it represents, and may in addition
describe the kind of media which is currently in the drive.

   There are two kind of floppy devices:
   * Variable geometry device nodes. Their minor number doesn't depend
     on the media in the drive, and is calculated as follows:
          MINOR_DEVICE = 128 * FDC_NR + UNIT_NR

   * Fixed geometry device nodes. Their minor number not only depends
     on the drive which they represent, but also the type of media
     currently in the drive.  It is computed as follows:

          MINOR_DEVICE = 128 * FDC_NR + UNIT_NR + 4 * FORMAT_NR

   In this formula, FDC_NR is the number of the floppy disk controller
(0 or 1, usually 0), and UNIT_NR is the Unit number (0 to 3, 0 for Dos
drive `A:', and 1 for Dos drive `B:').  FORMAT_NR is only meaningful
for the fixed format devices. It describes the disk geometry that is
used.  It is an index into the _geometry list_ See geometry list.
Using all available controller numbers and all available drive numbers,
you may thus connect up to 8 floppy drives to a single Linux box.

Variable format devices
=======================

   Variable format devices don't have an intrinsic geometry.  When using
these devices, the geometry has to be set either by using autodetection
(see Autodetection), or by using the `FDSETPRM' or `FDGETPRM'
ioctl.  The latter ioctl can be issued using the `setfdprm' (see
setfdprm) and `getfdrpm' (see getfdprm) programs. With the
default settings, common formats are detected transparently, and you
can access any disk transparently using the variable format devices.

   The geometry information is kept as long as the disk is in the drive,
and is discarded as soon as the disk is removed, unless the geometry has
been declared _permanent_ by using setfdprm's `-p' flag (see
setfdprm).

Fixed format devices
====================

   Fixed format devices should not be used under normal circumstances.

   Fixed format devices have an intrinsic geometry.  They are useful for
the `fdformat' program (which is now considered obsolete), and for
booting off floppies which have formats that are different from the
default format (because during booting, there is no application that can
issue the otherwise needed `FDSETPRM' ioctl).

The geometry list
=================

   The floppy driver contains a builtin list of 32 formats.  This list
is used for two purposes:
   * It says which geometry is used for the _fixed format_ devices.

   * It is used for _autodetection_

   The following formats (geometries) are known:

*format_nr*
     *Format*

0
     autodetect

1
     360KB, 5.25" DD drive

2
     1200KB, 5.25" HD drive

3
     360KB, 3.5" DD drive

4
     720KB, 3.5" DD drive

5
     360KB, 5.25" DD disk in HD drive

6
     720KB, 5.25" DD disk in HD drive

7
     1440KB, 3.5" HD drive

8
     2880KB, 3.5" ED drive

9
     3120KB, 3.5" ED drive

10
     1440KB, 5.25" HD drive

11
     1680KB, 3.5" HD drive

12
     410KB, 5.25" DD disk in HD drive

13
     820KB, 3.5" DD drive

14
     1476KB, 5.25" HD drive

15
     1722KB, 3.5" HD drive

16
     420KB, 5.25" DD disk in HD drive

17
     830KB, 3.5" DD drive

18
     1494KB, 5.25" HD drive

19
     1743KB, 3.5" HD drive

20
     880KB, 5.25" DD drive

21
     1040KB, 3.5" DD drive

22
     1120KB, 3.5" DD drive

23
     1600KB, 5.25" HD drive

24
     1760KB, 3.5" HD drive

25
     1920KB, 3.5" HD drive

26
     3200KB, 3.5" ED drive

27
     3520KB, 3.5" ED drive

28
     3840KB, 3.5" ED drive

29
     1840KB, 3.5" HD drive

30
     800KB, 3.5" DD drive

31
     1600KB, 3.5" HD drive

   This table lists first the format_nr (0-31) used to compute the minor
number, then the capacity of the format (360KB - 3200KB), and then the
type of the drive in which this format is used.

   The formats 0..8 are the standard PC formats.  The remaining formats
are extended capacity formats. Some of them have been taken from Heiko
Schroeder's fdpatches (after correcting some minor bugs).  Others have
been added by David Niemi and me (Alain Knaff).  Formats 9, 12, 13, 16,
17, 30 and 31 are non-interleaved formats with normal sized sectors, and
have the highest capacity that can be achieved without resorting to
interleaving or bigger sectors (see More sectors).  Formats 10, 11,
14, 15, 18, 19 use interleaving interleaving to achieve a higher
capacity (see Interleave).  Formats 20 and 22 to 29 use bigger
sectors than usual (see Larger sectors and Mixed size sectors).

   In addition to these techniques, formats 13-19 use more cylinders
than usual (see More cylinders).  *USE THESE FORMATS (13-19) ONLY IF
YOUR DRIVE SUPPORTS THE NECESSARY NUMBER OF TRACKS*

Adding new formats
==================

   You can redefine the default formats using the setfdprm program
(see setfdprm) (1).  The following example illustrates how to add a
new 19 sector format, and make a device entry for it.  First, we pick
an entry for it, which we want to reuse.  I recommend to redefine an
entry which is only rarely used.  For instance, if you have no 5 1/4
drive on your system, you can redefine any 5 1/4 entry without a loss.
In our example, we pick 10.

   First we make the device node:
     mknod /dev/fd0H1520 b 2 40
              ^          ^ ^  ^
              |          | |  Minor device number (format number * 4 +
              |          | |                       drive + controller*128)
              |          | Major device number (always 2!)
              |          Blockdevice
         A name that you choose for the format. I
         recommend to base the name on the capacity,
         but you may choose any name you want.

   Then we redefine the geometry of the new device:
     setfdprm /dev/fd0H1520 1520 19 2 80 0 0x1b 0 0xcf 0x6c

   *Note:* This redefines the geometry for any device node with the
same format number, not just the new node.

   The new geometry is only valid until the next reboot (or removal of
the floppy module).  In order to make it permanent, you have to execute
the `setfdprm' command from your `/etc/rc' file or whenever you insert
the floppy module.

   ---------- Footnotes ----------

   (1) In that case, the `MAKEFLOPPIES' program (see makefloppies)
no longer works to generate a correct name for these formats, and you
have to make them manually.

Media description
*****************

Introduction
============

   Fdutils-5.0 introduces a new uniform format description, which is
supported both by setfdprm and superformat.  The new format description
is easyer to handle, because it allows to set the different parameters
of a format description in a symbolic and position independant way,
using a series of _variable=value_ clauses.  Moreover, it automatically
fills in sensible default values for unspecified parameters.  Thus you
only need to describe those aspects of the format that are important to
you, and let the system handle the others.

   Moreover, the new description separates those aspects that were
specific to the drive (like for instance its rotation speed) from those
that are specific to the media (spacial density, number of sectors,
etc.).

   The same description can be used both by setfdprm and superformat:
     setfdprm /dev/fd0 hd sect=21 cyl=83
     superformat /dev/fd0 hd sect=21 cyl=83

   The first line above configures a 21 sector/83 cylinder format for
drive 0, and the second line formats a disk using this same format.

Syntax
======

   A media description is a series of _variable=value_ and _selector_
clauses. _Value_ is a number followed by an optional unit.  The unit is
either `KB' (1024 bytes) or `b' (blocks of 512 bytes), or none (bytes).

Selecting the density
---------------------

   To select a density just insert its two letter code into the format
description.  Selecting a density also selects its default number of
sectors, heads and cylinders.  However, these latter parameters can be
overridden.

`hd'
     High density (1440KB for 3 1/2 and 1200KB for 5 1/4).  The most
     commonly used format today.

`dd'
     Double density (720KB for 3 1/2 and 360KB for 5 1/4)

`ed'
     Extra density (2880KB for 3 1/2)

`qd'
     Quad density (720KB for 5 1/4).

`sd'
     Single density (no nominal size).  Used mostly for CP/M.  Only for
     experienced users.

   If no density is given, the maximal density supported by the drive is
used.  However, in order to keep the drive description and the media
description independent, I strongly suggest that you *always* indicate
the density anyways.

Selecting the number of cylinders, heads and sectors
----------------------------------------------------

   This subsection describes how to select custom formats with a
non-standard number of heads, cylinders or sectors.  However, note that
just describing the number of sectors, heads and cylinders is not
enough: you also need to indicate which density your custom format is
based on (cf. previous section).

`sect=_nb_of_sectors_'
     This describes the number of sectors.

`head=_nb_of_heads_'
     This describes the number of heads to be used.

`cyl=_nb_of_cylinders_'
     This described the number of cylinders to be used.

Selecting non-standard sector sizes
-----------------------------------

   In order to achieve a higher capacity, you may want to use a bigger
sector size.

`ssize=_sector_size_'
     Choses a bigger sector size.  The sector size is expressed in
     bytes.  Only powers of two between 128 and 32768 are acceptable

`sect=_nb_of_sectors_'
     Describes the number of sectors.  For example `hd sect=11
     ssize=1024' describes a format where one track (1 side) is made up
     of 11 sectors of 1024 bytes each (thus 11KB per track, and 22KB
     per cylinder).

`tracksize=_size_of_one_track_'
     Describes the size of one track.  For example, `hd tracksize=11KB
     ssize=1KB' describes a format where one track contains 11KB of data
     (tracksize) stored in sectors of 1KB each.

     This option exists mainly to describe MSS (mixed sector size)
     formats.  For example, `hd tracksize=12KB mss' describes a format
     where one track which contains 12 KB of data.  The sectors size
     are chosen by the system in a way to take up the least raw space:
     8KB + 4KB.

`mss'
     This option says that the format is an MSS format.

`2m'
     This option says that the format is a so-called 2M format.  These
     formats are intended for easy readability on DOS boxes.  Their
     first track has the usual 18 sectors, whereas the other tracks
     have bigger sector, and in some cases mixed sector sizes.

Legacy formats
--------------

   The `swapsides' format allows to descibe disks whose sides are
swapped, such as CBM1581 disks.

Expert options
--------------

   The following options are not needed in most common situations, as
they are implied by the _density_ selector.  They may be needed to read
some legacy (CP/M) formats.

`tpi=48'
     For 5 1/4 disks only.  This says that the format uses double-spaced
     cylinders (implied by double density).

`tpi=96'
     For 5 1/4 disks only.  This says that the format uses single-spaced
     cylinders (implied by quad and high density).

`fm=0'
     Uses MFM encoding (implied by double, quad, high and extra density)

`fm=1'
     Uses FM encoding (implied by single density)

`dtr=_dtr-code_'
     Sets the data transfer rate.  The following table lists the dtr
     codes for various transfer rates:
          dtr-code    rate for FM          rate for MFM
          =============================================
          0           250kb/s              500kb/s
          1           150kb/s              300kb/s
          2           125kb/s              250kb/s
          3           500kb/s              1000kb/s

`perp=0'
     Do not use "perpendicular mode" sector headers (this setting is
     implied by single, double, quad and high density).

`perp=1'
     Use "perpendicular" sector headers (this setting is implied by
     extra-density)

`gap=_value_'
     Sets the size of the read/write gap.  I don't know the purpose of
     this parameter (which is passed _as-is_ to the floppy controller):
     any value seems to work with any format...

`fmt_gap=_value_'
     Sets the size of the formatting gap.  This is only used by the now
     obsolete `fdformat' program, and not by superformat.

The media description dictionary in /etc/fdmediaprm
===================================================

   `/usr/local/etc/fdmediaprm' (1) contains a dictionary of commonly
used media descriptions.  Each description is identified by a name,
which can then be used by setfdprm or superformat to refer to it,
instead of an explicit description.

   Each definition starts with `"'_name_`":', followed by the actual
description.  Definitions may be spread over several lines, for better
readability.  The file may contain comments, which start with # and
stop at the end of the line.

   ---------- Footnotes ----------

   (1) The actual location of this file depends on the value of the
`sysconfdir' compile time configuration variable (see Compile-time configuration
for details)

Drive descriptions
******************

   Unlike earlyer version, fdutils-5.0 separates drive descriptions and
media description.  For more details on this separation, see
Introduction.  Drive descriptions are used to describe the hardware
characteristics of a drive, such as their maximal density, their
rotation speed, their form factor, etc.

Syntax
======

   A drive description is a series of _variable=value_ and _selector_
clauses.

Density
-------

   The density of a drive is the highest media density that it supports.
Density is one of `sd', `dd', `qd', `hd' or `ed'.  Usually, you do not
need to specify this parameter, as it can be derived from the drives
CMOS code.

Form factor
-----------

   The form factor of a drive describes the physical dimensions of the
media it accepts.  It is one of `3.5', `5.25' or `8'.  Usually, you do
not need to specify this parameter, as it can be derived from the
drives CMOS code.

Cmos code
---------

   The PC Bios already knows on its own about the most common drive
types.  These are named by an integer from 1 to 6, according to the
following table.
     0        no drive installed
     1        5.25 DD
     2        5.25 HD
     3        3.5 DD
     4        3.5 HD
     5        3.5 ED
     6        3.5 ED

   As you see 3.5 ED drives have two possible codes.  Some BIOSes use 5,
others use 6.  The reason for this is that initially 5 was intended for
floppy tape drives, and only 6 was for 3.5 ED drives.  However, some
BIOS manufacturers didn't know about this convention, and used 5 for the
then "new" 3.5 ED drives.

   Usually, you do not need to specify this parameter, as it can be read
from the physical CMOS of your PC.  This parameter may be useful if your
BIOS does not store the drive's CMOS code at the expected place, or if
you have more than two drives.

Other parameters
----------------

`deviation=DEVIATION'
     Tells how much more/less raw capacity the drive has than the
     standard.  Due to slightly different rotation speeds (1) and to
     slightly different data transfer rates, the raw capacity per track
     can vary slightly.  For normal formats, these small deviations
     from the prescribed raw capacity is not harmful, as these have
     plenty of safety margins built in.  However, the new extra
     capacity formats are affected by this, as they try to squeeze
     every available raw byte out of the disk.

     Deviation is expressed in ppm.  Positive values mean a higher raw
     capacity than normal, and negative values mean a lower raw
     capacity than normal.  The deviation can be measured using the
     `floppymeter' program.

`rpm=ROTATION_SPEED'
     Prescribed rotation speed of the drive, expressed in rotations per
     minute.  This is 360 for 5 1/4 HD drives, and 300 for all other
     commonly available drive types.  Usually, you do not need to
     specify this parameter, as it can be derived from the drive's CMOS
     code.  It is useful however for single density drives or other
     drives not commonly found on a PC.  Usually, you do not to specify
     this parameter, as it can be derived from the drive's form factor
     and maximal density.

`tpi=CYLINDER_DENSITY'
     This parameter is only meaningful for 5 1/4 drives.  It expresses
     whether the drive is able to use 80 tracks (`tpi=96') or only 40
     (`tpi=48').  Usually, you do not to specify this parameter, as it
     can be derived from the drive's maximal density: quad density and
     high density drives are 96 tpi, whereas double density drives are
     48 tpi.

   ---------- Footnotes ----------

   (1) drives do not always rotate at exactly 5 or 6 rotations per
second, but some may be slightly faster or slightly slower than spec

The drive definition file in `/usr/local/etc/fddriveprm'
========================================================

   `/usr/local/etc/fddriveprm' (1) contains a dictionary of commonly
used media descriptions.  Each description is identified by a name,
which can then be used by setfdprm or superformat to refer to it,
instead of an explicit description.

   Each definition starts with `"drive'_number_`":', followed by the
actual description.  Definitions may be spread over several lines, for
better readability.  The file may contain comments, which start with #
and stop at the end of the line.

   ---------- Footnotes ----------

   (1) The actual location of this file depends on the value of the
`sysconfdir' compile time configuration variable (see Compile-time configuration
for details)

Storing more data on a floppy disk
**********************************

   This section describes the techniques that are used by Linux' floppy
driver and superformat to store more data than usual on a floppy disk.

   Each section contains a description of the technique used, lists the
usages of the disks formatted using this technique (whether they are
bootable, whether they are accessible on MS-DOS and for which kind of
filesystems they are suitable) and finishes with a table listing the
most interesting formats which can be obtained by the described
technique.

   The table lists for each format the media type it is used for, the
total capacity which can be achieved, the throughput for large reads or
writes and the media description for these disks.  This description can
the be used with superformat to make such disks, or with setfdprm to
configure the drive to read/write to them.  Some formats (the XDF and
XXDF formats) cannot be accessed directly, and thus there is no media
description for them.  For these, we indicate a formatting command used
to make these disks.  The formatting command assume that the disk is in
the first drive (`/dev/fd0').  Substitute `/dev/fd1' if you want to
format XDF or XXDF disks in the second drive.

More sectors per cylinder
=========================

   The official formats used by MS-DOS and other operating systems are
generally very conservative.  It is often possible to fit more sectors
on each track than the default by simply reducing the size of the gap
between tracks and/or the size of the leftover space at the end of the
disk.

   For example, a 3 1/2 disk has a raw track capacity of around 12500
bytes.  The raw capacity of a floppy disk is not rigorously constant
among different boxes, because both the data transfer rate of the floppy
controller, and the rotation speed of the drive are subject to small
variations.  In order to account for these, we have to use a safety
margin, and we only use up 12450 bytes of the 12500 bytes that are
theoretically available.

   A sector contains a header of 62 bytes and 512 bytes of data.  A
minimum gap of about 45 bytes should be used in order to leave enough
time to the floppy controller to "rest" between reading two successive
sectors.  In total, 619 bytes per sector are thus needed.

   This shows that we can fit 12450 / 619 = 20 sectors per track.

   *Usage:* These disks are bootable by Lilo, and can be read in MS-DOS
using numerous shareware utilities such as `vgacopy', or `fdformat' or
many others.  Check your nearest Simtel mirror.

   With dos6, you don't need any add-on utilities, just put the
following line in your `config.sys':

     drivparm=/d:0 /f:7 /h:2 /s:21 /t:82
                 ^    ^ \______________/
                 |    |          |
        drive number  |     max geometry
                      |
           drive type, consult the dos help system for details

   *Interesting Formats:*

     density     tot. cap.    throughput    media description
     5 1/4 DD     800KB        30KB/s       dd sect=10
     3 1/2 DD     800KB        25KB/s       dd sect=10
     3 1/2 HD    1600KB        50KB/s       hd sect=21
     3 1/2 ED    3200KB       100KB/s       ed sect=42

   The `--dd', `--hd' and `--ed' options describe the density of the
media to be formatted (double density, high density or extra density).

   The `-s' options describes the number of 512 byte sectors per track.

Using interleave
================

   After having read a sector, the floppy controller needs to "rest"
for a short time.  This time is used to compute checksums, to reset
internal circuitry, etc.  During this time, the floppy disk continues
to rotate, and the "rest" time thusly translates to a certain minimal
gap size.  If a smaller gap is used, the next sector header flies by
the read-write head before the floppy controller is ready again to pick
up the data.  Thus, it has to wait until the next disk rotation until
that sector comes back again.  This leads to an unacceptably low
throughput, as now the system can only read one sector per rotation
instead of all sectors in one rotation.  If we want to use smaller
gaps, we have thus to use _sector interleaving_.  This technique
consists in arranging the sectors in a way such that the next logical
sector does not immediately follow the current sector, but instead
another sector is inserted between two successive sectors.  Instead of
having the following order:
     1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21

   we would use the following order:

     1,12,2,13,3,14,4,15,5,16,6,17,7,18,8,19,9,20,10,21,11,

   This new order allows the floppy controller to rest during the whole
time that sector 12 flies by between reading sector 1 and 2.  This
technique still cuts throughput in half, because two rotations are
needed (one for reading sectors 1 to 11, and the second to read sectors
12 to 21).  However, this is far better than the 21 rotations which
would be needed without interleave.

   This technique allows us to use a gap size of just 1, and thus fit 21
sectors on one track.

   *Usage:* Once formatted, interleaved disks can be used in a similar
way to disks which have simply more tracks.  They can be accessed using
`vgacopy' in Dos, you can boot from them using Lilo, and you may
install any filesystem on them.

   *Interesting Formats:*

     density     tot. cap.    throughput    media description
     5 1/4 HD    1440KB        27KB/s       hd sect=18
     3 1/2 HD    1680KB        26KB/s       hd sect=21
     3 1/2 ED    3360KB        52KB/s       ed sect=42

   You don't need to tell `superformat' to use interleaving, it figures
out by itself when interleaving is needed.  You don't need to tell
`setfdprm' either that a disk is interleaved, as this information is
not needed to read the disk

Sector skewing
==============

   Sector skewing is a technique that allows bigger throughputs.  It
does not increase the capacity of the disk. Sector skewing is only
relevant during formatting. Sector skewed disks are indistinguishable
from non-skewed disk by software, except for a different throughput.

   The principle of sector skewing is to start each track a little bit
later than the previous one, i.e. the first logical sector of the second
cylinder would for exemple lie near the sixth logical sector of the
first cylinder.  This is done in order to account for the time needed to
seek the drive head from the first cylinder to the second.  Without
skewing, the first sector would already have passed the drive head after
seeking, and we would need to wait for a whole rotation for it to come
back again.

   By default, superformat applies appropriate skewing to all formats,
and the listed throughput values refer to skewed disks. It is possible
to provide different values for the skew using the `--head_skew' and
`--track_skew' parameters. `head_skew' refers to the offset between
both sides of the same cylinder, and `track_skew' refers to the offset
of two consecutive cylinders. 0 means no skew.

More Cylinders
==============

   Many nominally 40-cylinders or 80-cylinder drives are capable of more
cylinders, usually 41 and 83 respectively.  These can be used to get
extra capacity.  However, not all drives can seek to these unofficial
extra cylinders, and even on drives which can, these extra cylinders
tend to be less reliable.

   *WARNING*: Although most drives are able to use 83 cylinders, some
may not.  If your drive is making strange noises while accessing these
tracks.

   Although most drives support more than 80 tracks, I have heard rumors
that some do not, and repeatedly trying to read beyond track 80 might be
damaging to them.  In order to know wether your drive supports more than
eighty tracks, first set the number of allowed tracks to 82.  (using
`floppycontrol --cylinders 82 -d 'DRIVE)

   Then format a disk with a 82 track format (for example
`/dev/fd0H1722'), and copy on or several files to the disk until there
are less than 18 KB of free space on the disk.  Then eject and reinsert
the disk, and compare the files on the disk with the originals. If they
are the same, your drive does support 82 tracks. If so, you might want
to go further and try with 83 cylinders: `/dev/fd0H1743') This single
experience should not damage the drive, although repeating it many
times may be dangerous.

   If you do have a drive which supports more than 80 cylinders, you
have to call `floppycontrol --cylinders 82 DRIVE' before you can use
the extra cylinders.  You may put this line into your `/etc/rc.local',
so that the driver is automatically configured for the addition
cylinder after each boot.

   If on the other hand your drive doesn't support more than 80 tracks,
you should remove the entries for formats 13-19 from your `/dev'
directory after running `MAKEFLOPPIES', and you should call
`floppycontrol --cylinder 80 DRIVE' from your `/etc/rc.local' (or
`floppycontrol --cylinder 40 DRIVE' for 5 1/4 DD drives).

   By default, 83 cylinder are enabled for any high density and double
density drives.  3 1/2 double density drives have 80 cylinders enables,
and 5 1/4 double density drives have 40 enabled.

   *Usage:* These disks can be booted from using LILO, and can be
accessed in MS-DOS using `vgacopy'.

   *Interesting Formats:*

   All formats presented in the two previous sections may be amended to
use 83 cylinders instead of 80. Just add the `cyl=83' to the format
description for superformat.  Using more cylinders has no effect on the
throughput.

     density     tot. cap.    throughput    media description
     5 1/4 HD    1494KB        27KB/s       hd sect=18 cyl=83
     3 1/2 HD    1743KB        26KB/s       hd sect=21 cyl=83
     3 1/2 ED    3486KB        52KB/s       ed sect=42 cyl=83

Larger sectors
==============

   The floppy controller allows us to use larger sectors than the
default size of 512 bytes. All powers of two larger than 256 bytes are
acceptable sector sizes.  Large sectors have the same header and gap
sizes than smaller sectors, thus the overhead per byte of data is
smaller.  A little calculation shows this: A 1024 byte sector takes up
at least 1024+62+1 = 1087 raw bytes.  You can fit eleven sectors of this
size into a 12450 byte track.  This represents 11KB of data per track,
versus the 10.5KB only that can be achieved with 512 byte sectors.

   *Usage:* MS-DOS and other operating systems cannot normally read
these formats.  Lilo is not yet able to boot from this kind of disks.

   *Performance:* When any portion of one of these larger sectors is
read, the entire sector must be read.  When any portion of such a sector
is written to, the entire sector must be read, and then written back
with just the necessary portion modified.  Both of these circumstances
can entail worse performance than are listed in this table for small
reads and (especially) small writes.

   *Interesting Formats:*

     density     tot. cap.    throughput  media description
     5 1/4 HD    1440KB        30KB/s     dd sect=9 ssize=1KB
     3 1/2 HD    1760KB        55KB/s     hd sect=11 ssize=1KB
     3 1/2 ED    3520KB       110KB/s     ed sect=11 ssize=2KB

   The `ssize' parameter of the format description indicates the sector
size to be used.

Mixed sector size (MSS) formats
===============================

   Using larger sectors has the disadvantage that the granularity is
larger.  For example, when using 4096 byte sectors, there is enough
space to fit two sectors in a track of 12450 bytes raw capacity, but not
three.  However, the two sector format leaves plenty of space available
(4132 bytes), in which smaller sectors would fit.  For example, these
4142 raw bytes can be put to good use by filling them with a 2 KB sector
(2048+62), plus an 1 KB sector (1024+62) and a 512 byte sector, leaving
still 362 bytes for gaps.

   Mixed sector size formats take advantage of this by using sectors of
several different sizes on a same track.  This way, a maximum capacity
of 12KB per track, distributed in one 8k sector and one 4k sector can be
achieved.

   *Usage:* There is no known MS-DOS utility which can read basic MSS
disks.  Lilo is not yet able to boot from this kind of disks.

   *Performance:* As any format with larger sectors, the performance
for small reads and writes is worse due to the larger granularity.

   *Interesting Formats:*

     density     tot. cap.    throughput    media description
     3 1/2 DD     880KB        28KB/s       hd tracksize=11b mss
     5 1/4 HD    1600KB        30KB/s       hd tracksize=10KB mss
     3 1/2 DD     880KB        28KB/s       hd tracksize=11b mss
     3 1/2 HD    1840KB        28KB/s       hd tracksize=23b mss
     3 1/2 HD    1920KB        30KB/s       hd tracksize=12KB mss
     3 1/2 ED    3680KB        56KB/s       ed tracksize=23KB mss
     3 1/2 ED    3840KB        60KB/s       ed tracksize=24KB mss

   For MSS formats, the system figures out the most efficient
repartition of sector sizes by itself.  You do not need to describe the
number of sectors and their size.  For MSS disks, the capacity of one
track is described directly, using the `tracksize' parameter.

   The `1920KB' and `3840KB' formats may be unreliable on some
computers.