The Floppy Diskette How To

revision 2004-DEC-13

Generalities

Three reasons for using floppies

  1. To transfer files between the SUN's and some other computer such as your home computer. Using floppies is much faster than using "ftp" and a modem connection to transfer files. Files larger than 200 kB will take 10 or more minutes at current modem connection speeds.

  2. As an archive: backup copies of files.

  3. To extend the effective amount of file space available to you.

Three ways to use floppies - DOS, UFS and TAR

You can use a floppy either as a DOS formatted floppy, as a UFS (Unix File System) floppy or as a TAR floppy.

For transferring files the recommended choice is TAR if you have Linux on your home computer or wish to transfer files to another Unix system. Tar is the standard way to transfer files between different Unix systems.

Do not use UFS floppies unless you are transferring to a SUN or closely related system.

Use DOS if you're stuck with a Microsoft only system at home.

Many Unix systems can also read DOS disks, so this may be an option if you are not sure what your target machine will be, if you are transfering to a different university or job.

For archiving files, the recommended choice is TAR, although the other two could also be used. Be careful not to overwrite files already on the disk.

To extend the amount of file space the recommended choice is UFS although TAR might also be useful in certain circumstances.

File systems on floppies

DOS and UFS floppies

DOS and UFS floppies have file systems on them: the files appear in the Unix file tree and you can "cd" and "cp" just like with regular files. The best way to enter the floppy file system is at /floppy/floppy0 which points to the top of the floppy file tree.

For example: cp $HOME/program.c /floppy/floppy0 puts a copy of program.c into the top directory of the floppy.

There are other ways to get at the file system under /floppy but the above will always work regardless of the label the floppy has.

TAR floppies

TAR floppies do not have file systems on them. The only way to access files is through the "tar" command.

Raw device access

All floppies, as with any UNIX I/O device, can be accessed through device files. For floppies the device is /vol/dev/aliases/floppy0 There are other was to access the device, such as /vol/dev/rdiskette0, but /vol/dev/aliases/floppy0 will work regardless of type of floppy.

DOS file problems

DOS text files have carriage returns.

Each line in a Unix text file ends with a newline. Each line in a DOS text file ends with a newline and a carriage return.

Newlines are referred to as \n, \012, ENTER, CTRL-J, ^J depending on context. Carriage returns are \r, \015, CTRL-M, ^M.

If on your DOS system a file you transferred prints so that each successive line starts where the previous line left off instead of at the left margin then you forgot to "add" the carriage returns to the file.

If on Unix the file has "^M" at the end of every line when you attempt to edit it, it's because you forgot to strip off the carriage returns on a DOS file.

To convert between these types use dos2unix of unix2dos:

  • DOS to unix file: dos2unix -ascii <from_dos_file> <to_unix_file>
  • Unix to dos file: unix2dos -ascii <from_unix_file> <to_dos_file>

The two file names can be the same, in which case the transformation is done in place.

The "tr" utility can also be used for stripping away the ^M characters at the end of each line: tr -s '\r\n' '\n' <from_dos_file >to_unix_file

DOS file names are 8 + 3

DOS file names are of form cccccccc.xxx

Unix file names will be truncated to fit this pattern. Watch out for files with dots in them such as test.c.new and .profile

One way to try to avoid problems is to use tar or zip to create a archive and copy the archive over. Tar also has the advantage of preserving dates, ownership and permissions on files.

Protections are too permissive on DOS floppies.

A DOS floppy is readable and writable by world so should not be left in the drive any longer than necessary. Files copied from a floppy may have permissive protections, often writable by anyone. Check any file copied off the floppy with "ls -l" and use "chmod o-rwx " as needed.

Handling large files: Use gzip and/or TAR floppies

Floppies have room for up to 1.44 MB of data, but what happens if you have a larger file? You can use the "split" command but it is awkward.

TAR floppies, when written with the GNU "tar" command can span floppies. For moving large files use a TAR floppy.

You can use "gzip" to compress large files, especially text files, to save space.

Floppy reliability

Floppies are not as reliable as hard disks and are easily damaged. Floppies are cheap but data is valuable! Throw away any suspect or old floppy.

You should always make two floppy copies of anything important and save them in different places. When transferring files do not delete the hard disk copy until the transfer is complete.

Specific Instructions

First step is always "volcheck"

The system does not check the floppy drive for media changes as continual polling would wear out the drive, thus it is up to you to tell the system whenever the media is changed. The first step always is to issue command: volcheck

A program called the "volume manager" will make the floppy available to you in two places. If the floppy has a file system on it (DOS and UFS floppies) then the file system will be at /floppy/floppy0. It is also at a few other places under /floppy, but /floppy/floppy0 is the generic way to get at the file system.

Whether or not the floppy has a file system, the floppy is also accessible through /vol/dev/aliases/floppy0 and also at other non-generic places under /vol such as /vol/dev/rdiskette0. This is were the "device" file is, the place in Unix through which the actual floppy I/O goes.

The last step is always "eject floppy" or "eject".

Issue command "eject" to retrieve the floppy. If the machine also has a CD drive on it you'll need to use "eject floppy".

Problems?

If you get a response like: "/vol/dev/rdiskette0/*: Device busy" the system is telling you that some program is still using the floppy.

  • Are you still in the /floppy/floppy0 directory? If so "cd" to some other directory.
  • Are you still editing a file on the floppy? Is so close the edit.

Although the following are not recommended since they do not clean up the file system, in those rare panicky situations: * The floppy can be physically ejected by inserting a paper clip in the adjacent hole.
* The super user can eject a floppy at the eeprom level also.

Formatting floppies

All floppies need to be formatted before being used. Most floppies are already DOS formatted by the manufacturer, so often you can skip this step if you want a DOS floppy. However, if you want to switch a floppy from a TAR to a DOS or UFS floppy you will need to format it first.

"fdformat" (Floppy Disk FORMAT) is the command. There are options for labeling the disk (-b) and for formatting disks other than standard 1.44 MB disks. You can not format a diskette with bad sectors - throw the floppy away - see "Floppy Reliability" above.

If the floppy was a DOS or UFS floppy previously you need to use the "-U" option on fdformat to get rid of the previous file system.
fdformat will tell you if this is necessary. After formatting it is necessary to eject the disk and reinsert it, if you want to access the file system on the newly formatted floppy.

DOS floppies

  1. volcheck
  2. fdformat -d -e OR fdformat -U -d -e

The "-e" ejects the floppy after formatting and saves having to type an "eject" command. fdformat does not make a bootable floppy although there are options for installing boot loaders. fdformat -d also puts an MS-DOS file system on the disk.

UFS floppies

  1. volcheck
  2. fdformat OR fdformat -U This formats the floppy.
  3. Next you need to put a Unix file system on the floppy. This creates a directory "lost+found" which you should never delete:

    newfs -v /vol/dev/aliases/floppy0

  4. Afterwards eject the floppy, as the new file system will not be recognized yet:

    eject

  5. Afterwards you may reinsert the floppy, issue command "volcheck" and start using the floppy.

TAR floppies

  1. volcheck
  2. fdformat OR fdformat -U

Since TAR floppies have no file system they can be used without first ejecting them.

Using DOS or UFS floppies

  1. Format the diskette if necessary.
  2. Insert diskette.
  3. Issue command: "volcheck"
  4. Copy files to or from the floppy. You might even use tar to copy directories. The floppies files are located at /floppy/floppy0 and below.
  5. When done, issue command "eject floppy"

Using TAR floppies

  1. Format the diskette(s) if necessary.
  2. Insert the first diskette.
  3. Issue command: "volcheck"
  4. "cd" to the directory containing the files or subdirectories you want to put on the floppy, or to the directory where you want to put the files from the floppy.
  5. Issue command: "/usr/local/bin/tar" with options from "The tar command" below.

If the files will span multiple floppies, then "tar" will say something like: "Prepare volume #2 for /vol/dev/aliases/floppy0 and hit return:"

You will need to open a new terminal window, issue command "eject", insert the next floppy, issue command "volcheck" and when the volcheck is done, hit the return key in the original window. Continue in this manner.

When done, issue command "eject" to get the last floppy back.

The tar command - use GNU tar

You must use the GNU tar: /usr/local/bin/tar, not the default SUN tar: /usr/bin/tar, as the SUN tar can not handle multiple floppies or long file names.

Probably you'll use one of these forms:

/usr/local/bin/tar -cvMf  /vol/dev/aliases/floppy0 <dirs>
/usr/local/bin/tar -avMf  /vol/dev/aliases/floppy0 <dirs>
/usr/local/bin/tar -xpvMf /vol/dev/aliases/floppy0 
/usr/local/bin/tar -tMf   /vol/dev/aliases/floppy0
  • -c means to create the tar file on the floppy (and destroy anything that might be there before).
  • -a means to append to an existing tar file on the floppy
  • -x means to extract, that is, copy files from the floppy to the current directory
  • -t means to give a table, that is, list of what is in the tar file on the floppy.
  • -f means from the following device or file

These are optional:

  • -M says to allow the tar file to span multiple floppies.
  • -v means verbose: show files are they are added or extracted.
  • -p means preserve: take the ownership and protections as recorded in the tar file.
  • -z means gzip the files too (only works with gnu tar)

<dirs> are names of directories (or files) to add to the tar file. If a directory is specified the directory is recursively descended. You can also specify them for an extract "-x" if you don't want all files. Just specify the ones you want.