Manipulating
Floppy Disk Images on SolarisTM
Ed Schaefer and John Spurgeon
With the advent of CD and DVD burners, USB flash drives, and high
speed networks, floppy drives are becoming passé. For some
administrators, however, floppies are still a convenient way to
transfer and store small amounts of data. Moreover, a floppy drive
may be required to install hardware drivers and other software that
is still distributed on diskette.
On Solaris, the floppy drive may be controlled with the following
commands:
volrmmount -- Call rmmount to mount or unmount media.
volcheck -- Check for media in a drive and by default check
all floppy media.
eject -- Eject media such as CD-ROM and floppy from the
drive.
Because we access the floppy drive infrequently, remembering what
commands to use and how they work is a challenge. To simplify the
process, we created three Korn shell scripts that can be used to
manipulate floppy disk images:
ls_floppy (Listing 1) -- Lists the contents of a diskette.
dd_to_floppy (Listing 2) -- Copies an image to a diskette (from
a file).
dd_from_floppy (Listing 3) -- Copies an image from a diskette
(to a file).
Listing the Contents of a Diskette
The ls_floppy script lists the contents of a diskette in the floppy
drive referenced by nickname:
ls_floppy [ -aAbcCdfFgilLmnopqrRstux1 ] [ nickname ... ]
If no operands are supplied, the nickname defaults to floppy. The
nickname is an alias for a device's pathname. For example, floppy
refers to /dev/rdiskette. For a list of valid nicknames, see volrmmount.
If a diskette is detected in the floppy drive, the script executes
the cd command to change to a directory corresponding to
the floppy drive, and the directory's contents are listed. The process
is repeated for each operand.
Note that ls_floppy supports the same options as the ls
command. For example:
ls_floppy -lr
provides a long listing in reverse order of the default floppy drive.
Copying an Image to a Diskette
The dd_to_floppy script copies an image from a file to a diskette.
Assume we want to copy an image in the current directory named DISK4
to a floppy. To begin, insert a floppy into the drive. (Make sure
there's nothing you want to keep on the floppy since it will be
overwritten.) Then execute:
dd_to_floppy DISK4
The script first unmounts the drive in case it was left in a mounted
state. Next, it mounts the drive using volcheck.
On our system, a new block file is created in the directory /vol/dev/diskette0/.
Because we've hard-coded this pathname in the script, you may need
to change it, or you might want to parameterize the value depending
on your hardware configuration.
The name of the block file is derived from the contents of the
diskette, so the script searches the directory and displays the
available block devices, forcing the user to select one before continuing.
For example, one of our diskettes generates the following prompt:
1) mlx_0109134
Select block file:
When the user selects 1), DISK4 is copied to the floppy using the
dd command. Substituting the values in our example for variables
in the script, the dd command that is executed looks like this:
dd if=DISK4 of=/vol/dev/diskette0/mlx_0109134
When the dd command completes, the floppy drive is unmounted.
Copying an Image from a Diskette
The dd_from_floppy script copies an image from the floppy drive.
To copy an image from a floppy to /home/eds/floppies/DISK4, execute:
dd_from_floppy /home/eds/floppies/DISK4
After the floppy is mounted, the user is prompted to select a block
file; remember that the name of the block file may vary depending
on the diskette:
1) no_name
Select block file:
After the user chooses 1), the following dd command is executed:
dd if=/vol/dev/diskette0/no_name of=/home/eds/floppies/DISK4
Again, when the dd command completes, the floppy drive is unmounted.
Copying Files to a Diskette
Because the ls_floppy script leaves the floppy drive in a mounted
state, we can use it to copy files to an existing filesystem on
the floppy using the cp command. Simply source the ls_floppy
script:
. ls_floppy
This mounts the drive and makes /floppy/floppy0 the working directory.
To copy the file /tmp/a.out to the floppy disk, execute:
cp /tmp/a.out .
Finally, we think the following alias is cute:
cd_floppy='. ls_floppy'
References
"How to Use Floppy Disks with Solaris" from a document originally
written by John Oleynick -- http://www.cs.rutgers.edu/~watrous/floppies-under-solaris.html
John Spurgeon is a software developer and systems administrator
for Intel's Factory Information Control Systems, IFICS, in Aloha,
Oregon. Outside of work, he enjoys turf grass management, triathlons,
and spending time with his family.
Ed Schaefer is a frequent contributor to Sys Admin.
He is a software developer and DBA for Intel's Factory Information
Control Systems, IFICS, in Aloha, Oregon. Ed also edits the monthly
Shell Corner column on UnixReview.com. He can be reached at: shellcorner@comcast.net. |