.TH  "floppy disks" "" "" "Technical Information"
.PC
.PP
.II "disk^floppy"
The \*(CO system lets you read or write to floppy disks, using
a variety of different formats.
You can choose the format that best suits the task at hand.
.SH "Disks Supported"
\*(CO lets you use either 3.5-inch or 5.25-inch disks, in either
high or low density; what you use depends upon the type of hardware
that you have.
The following table gives
some commonly used diskette device names and formats.
The minor number of each device is also given; note that all floppy-disk
devices have the major number of 4:
.DM
.ta 1.5iC 2.4iC 3.0iC 3.7iC 4.3iC 5.2iC
\fIDevice Name	Sectors/Track	Heads	Sectors	Bytes	Format	Minor Number\fP
/dev/f9a0	9	2	720	360 KB	5.25"	12
/dev/f9a1	9	2	720	360 KB	5.25"	28
/dev/fqa0	9	2	1440	720 KB	3.5"	13
/dev/fqa1	9	2	1440	720 KB	3.5"	29
/dev/fha0	15	2	2400	1.2 MB	5.25"	14
/dev/fha1	15	2	2400	1.2 MB	5.25"	30
/dev/fva0	18	2	2880	1.44 MB	3.5"	15
/dev/fva1	18	2	2880	1.44 MB	3.5"	31
.DE
.PP
Device names ending in `0' indicate drive A:,
names ending in `1' indicate drive B:.
For a fuller description of \*(CO's floppy-disk devices, see the
Lexicon entry for
.BR fd .
.SH "MS-DOS Format"
\*(CO lets you read or write to floppy disks that contain \*(MD
file systems.
Both tasks use the commands
.B doscp
or
.BR doscpdir .
These commands are discussed in full in their respective Lexicon entries.
.PP
.II "MS-DOS^reading floppy"
To read files from an \*(MD disk, use
.B doscp
with the name of the appropriate for the
floppy-disk device that you will be using
(as given in the above table).
For example, to copy binary file \fBfred.exe\fR to the current directory
from a low-density, 5.25-inch
\*(MD floppy disk in drive A, use the following command:
.DM
	doscp /dev/f9a0:fred.exe .
.DE
.PP
The following command copies to the current directory
all files on a high-density, 5.25-inch \*(MD floppy disk in drive B:
.DM
	doscp /dev/fha1:\e* .
.DE
.PP
To write a file to a preformatted \*(MD floppy disk, again use the
.B doscp
command, but invert the order of the arguments.
For example, to write file \fBfred.ms\fR, which contains text,
to a low-density, 5.25-inch
\*(MD floppy disk in drive A, use the following command:
.DM
	doscp -a fred.ms /dev/f9a0:
.DE
.PP
Note that the `a' flag in the command line tells \*(CO to convert
linefeeds to the linefeed/carriage return combination, as used by \*(MD.
You will want to use this flag \fIonly\fR when transferring text
files to or from an \*(MD floppy disk.
.PP
The following command copies all files in the current directory to
a high-density, 3.5-inch \*(MD floppy disk in drive B:
.DM
	doscpdir . /dev/fva1:
.DE
.PP
Note that when you copy a file to an \*(MD floppy disk, \*(CO
observes the \*(MD file-name conventions:
it permits only eight characters to the left of the period, and only
three characters to the right of it.
.PP
(It should be noted in passing that you can use the
.B doscp
or
.B doscpdir
to read files from or write files to an \*(MD partition on your
hard disk.
All that is necessary is to replace the name of floppy-disk device with
that of the hard-disk device for the partition in question.
See the Lexicon entry for
.B at
for a list of hard-disk devices; see the entry for
.B fdisk
for information on how to read the layout of your hard disk;
and see the entries for
.B doscp
and
.B doscpdir
for details of how to use these commands.)
.PP
Finally, \*(CO lets you format a floppy disk and create an \*(MD
file system on it.
To do so, you must use the commands
.B fdformat
and
.BR dosformat .
.B fdformat
is described in detail in its Lexicon article.
.PP
To format a high-density, 5.25-inch floppy disk in drive B and write
an \*(MD file system onto it, use the following commands:
.DM
	/etc/fdformat -av /dev/fha1
	dosformat /dev/fha1:
.DE
.SH "COHERENT Format"
If you wish, you can create a \*(CO file system on a floppy disk,
mount it, and use standard \*(CO commands to manipulate the files on it.
This illustrates well the fact that to \*(CO a file system
is a file system, whether it resides on a hard, a floppy disk, or any
other mass-storage device.
You can use such mountable floppy disks as an easy method of backing
up files, or as a flexible extension to any other file system that you
have currently mounted.
.PP
To create a \*(CO file system on a floppy disk, you must use
the commands \fBfdformat\fR and \fBmkfs\fR.
Each is described in detail in its own Lexicon article.
The following example creates a \*(CO file system on a high-density,
3.5-inch floppy disk placed in drive B:
.DM
	/etc/fdformat -av /dev/rfva1
	/etc/mkfs /dev/fva1 2880
.DE
.PP
In this example, command
.B fdformat
formatted the disk.
The option
.B -v
tells
.B fdformat
to use its verification mode.
This takes longer, but ensures that the disk is good.
If this command fails, it means that the floppy disk has a bad block
or sector:
throw it away and try again.
.PP
Command
.B mkfs
builds a \*(CO file system on the disk.
The file system has 2,880 blocks (1.44 megabytes) of space, which is
appropriate for a high-density, 3.5-inch floppy disk.
.PP
Now that the file system is created on the disk, you must mount it.
To do so, use the script
.BR mount ;
this is described in its Lexicon entry.
This mounts the file system on directory \fB/f0\fR if the disk drive is
drive 0 (A:); or \fBf1\fR if the disk drive is drive 1 (B:).
.PP
While it is customary to mount file systems under directory `/', you
are not required to do it.
For example, if your login identifier is
.B fred
and your home directory is
.BR /usr/fred ,
you can mount the floppy disk's file system onto a subdirectory of
.B /usr/fred
and so make the floppy disk, in effect, an extension of your home directory.
To mount a floppy on a directory other than its default, use the command
.BR /etc/mount .
The following command does this for the 3.5-inch disk we formatted in the
above example:
.DM
	/etc/mount /dev/fva1 /usr/fred/temp
.DE
.PP
Now, all files you copy into directory
.B /usr/fred/temp
using the \fBcp\fR command
will be written directly onto the floppy disk.
Note that you may need to log in as the superuser
.B root
and use the command
.B chown
to ensure that
.B fred
owns the file system on that floppy disk.
For details on
.BR chown ,
see its entry in the Lexicon.
For details on shorthand notations for
.BR mount ,
see its entry in the Lexicon.
.PP
One important point about mounting file systems:
before you remove a \*(CO-formatted floppy disk from its drive, you
\fBmust\fR first use the command
.B /etc/umount
to unmount its file system.
If you do not, all data that \*(CO has stored in its buffers will not be
written to the disk, and may be lost.
Worse, if you remove one \*(CO disk and insert another without unmounting
the old disk and mounting the new one, \*(CO will write all data in its
buffers onto the new disk without regard for what that disk contains; in
all likelihood, this will trash the file system on the new disk and render
its data unreadable.
So, the lesson is:
\fIalways unmount a floppy disk before you remove it!\fR.
To unmount the floppy disk we used in our previous example, use the command:
.DM
	/etc/umount /dev/fva1
.DE
.PP
By the way, that's not a misprint:
the command is
.BR umount ,
not ``unmount''.
.PP
.II "XENIX file system, mounting"
.II "MS-DOS^file system, mounting"
.II "file system^mounting non-COHERENT"
.II "non-COHERENT file system^mounting"
Finally, please note that you can mount only a \*(CO file system.
You \fIcannot\fR mount a file system created with \*(MD, XENIX,
or any other operating system.
.PP
You can, however \fIimport\fR a set of files \(em including their directory
structure \(em from \*(UN, XENIX,
or any other \*(UN-like operating system by
using the utilities.
.B cpio
or
.BR tar .
Each of these utilities
uses a backup algorithm that is implemented on many operating systems.
To import files from another operating system, go to the machine that holds
the files you want and use its version of
.B cpio
or
.B tar
to back up the files or directories to a set of floppy disks or
cartridge tape.
Then bring the floppy disks back to your \*(CO system and use \*(CO's
implementation of
.B cpio
to read the back-up disks.
The following section gives directions on how to do this; or see the Lexicon
entries for
.B cpio
and
.B tar
for more information.
.SH "Raw Format"
Finally, \*(CO lets you use floppy disks in their raw form
as a backup medium, much as you would use magnetic tape on a larger
computer.
You must first use the command
.B /etc/fdformat
with the
.B \-v
option to format the floppy disks you will be using; it is also wise to label
and number the disks so you can keep them in some reasonable order.
Then you can use any of \*(CO's archiving utilities, such as
.B tar
or
.BR cpio ,
to archive directories or entire file systems onto the disks.
It is recommended that you format a generous supply of floppy disks before
you begin; if you run short of disks while archiving your files, you will
have to abort, format more disks, and begin again.
For details on how to use the archiving programs, see their respective
entries in the Lexicon.
.SH Interleave
.II interleave
The ``interleave'' of a disk device refers to the pattern with which blocks
are scattered around a disk cylinder.
It can have a drastic effect on the speed with which data are read
from and written to a disk.
.PP
The interleave is set by the file system written onto that disk.
Thus, under \*(CO the interleave is set by the command
.BR /etc/mkfs .
By default, this command sets the interleave pattern to six.
You can request a different interleave pattern; however, the proper interleave
for a floppy disk can vary wildly, depending upon what disk drives you have,
your CPU speed, amount of RAM, and several other variables.
The best way to discover the interleave pattern is to experiment.
.PP
.II "Smith, Fred"
The following script, by Fred Smith (fredex%fcshome@merk.merk.com),
formats a floppy disk to a specified set of factors, generates a file
system, and runs a program to exercise it.
By running this program with a number of different settings, you can
find which is best for your system.
You will find this to be especially helpful if you work frequently with
floppy disks:
.DM
# usage: doit <interleave> <skew> <device name> <tracks (not sectors) per drive>
#   for a 3.5dshd in drive 1:  sh doit 3 6 fva1 2880
#   for a 5.25dshd in drive 0: sh doit 3 6 fha0 2400
# assumes that iozone is in the current directory, and that there is a
# subdirectory named 'test', over which the floppy can be mounted.
.DE
.DM
echo /etc/fdformat -a -i $1 -o $2 /dev/r$3
/etc/fdformat -a -i $1 -o $2 /dev/r$3
/etc/badscan -v -o flop /dev/$3 $4
.DE
.DM
# in case you want to modify the permissions of the new file system.
# if you don't want to do the vi, then run this as root.
#vi flop
.DE
.DM
	/etc/mkfs /dev/$3 flop
	/etc/mount /dev/$3 ./test
	cd test
	../iozone
	cd ..
	/etc/umount /dev/$3
.DE
.SH "Debugging Floppy-Disk Problems"
The \*(CO floppy-disk driver has been used frequently by tens of thousands
of users over a number of years, and has been found to be sound.
However, from time to time a problem can arise.
This usually occurs when users install new equipment into their systems.
If you continually see error messages that indicate a problem with the
floppy-disk drive, e.g.,
.BR "door open" ,
try the following steps to diagnose the problem:
.IP \fB1.\fR 0.3i
Is CMOS configured for the floppy-disk drives?
The CMOS on your machine may have been ``clobbered'' by an event that has
nothing to do with \*(CO \(em e.g., a power surge.
.IP
To check your CMOS, you can reboot your system; the BIOS on practically every
computer includes a program for reading and resetting the CMOS.
Or, you can read the output of device
.BR /dev/cmos .
The Lexicon entry
.B cmos
describes how to interpret the output of this device.
.IP \fB2.\fR
If you have switched hard drives, did you change IDE controllers or
alter any jumpers?
If the same card controls both floppy and hard drives, you may have moved
a jumper wrongly.
It may also be that the new controller has a bug.
.IP \fB3.\fR
Try using the command
.B /etc/conf/bin/idtune
to change the value of variable
.BR FL_DSK_CH_PROB ;
then use the command
.B /etc/conf/bin/idmkcoh
to link a new kernel, and boot the new kernel.
To check the current value of that variable (or of any tunable variable),
use the command
.BR "idtune \-p" .
.IP \fB4.\fR
Is any other equipment conflicting with the drive in question,
such as a QIC-80 or QIC-40 tape drive?
Try pulling the device in question, and see if that makes the problem go away.
.IP \fB5.\fR
Check that all cables are secure and all cards seated properly.
If your machine is loaded with equipment, its interior can be a rat's nest
of cables and connectors; and while installing new equipment, it is easy to
loosen a cable or jar a card so that it no longer works.
.IP \fB6.\fR
Try the following command with a floppy disk in place, just after you have
booted \*(CO and before any other access to the drive:
.DM
	dd if=/dev/r\fIdev\fP of=/dev/null count=2 bs=30b
.DE
.IP
.I dev
is names the floppy-disk device in question, e.g.,
.B fha0
or
.BR fva1 .
This command may help if the driver is not getting the recalibration status
it expects.
.IP \fB7.\fR
If all else fails, try swapping out the controller or drive.
It may be that the device simply has failed.
.SH "See Also"
.Xr "Administering COHERENT," administe
.Xr "badscan," badscan
.Xr "cpio," cpio
.Xr "doscp," doscp
.Xr "doscpdir," doscpdir
.Xr "dosformat," dosformat
.Xr "fd," fd
.Xr "fdformat," fdformat
.Xr "gtar," gtar
.Xr "mkfs," mkfs
.Xr "mount," mount
.Xr "umount" umount
.SH Notes
You can create a version of the \*(CO operating system that runs
from a floppy disk.
Such a version of \*(CO can be used to create test or backup systems for
device drivers or other applications.
For directions on how to make a version of \*(CO that boots from a floppy
disk, see the Lexicon entry
.BR booting .
