How can I format a floppy under HP-UX?

There is no HP-fully-supported way of getting an MS-DOS floppy formatted
on HP-UX. (Once you have a PC-compatible floppy, the series of commands
referenced in the dosif(4) manpage allow you to read and write the
floppies).

However, there is a workaround. Perform the basic mediainit with the
-f16 switch (this causes the floppy to beeeeeeeee formatted with the full
80
tracks, rather than HP's default safer-but-nonstandard 77+3spare tracks,
512-byte sectors, no sector skew: just like the most basic PC floppies).
Then copy on the FAT, directory, label, and other such magic from an
honest-to-goodness formatted-on-a-real-PC drive into the first N sectors.
For sizes up to 1.44MB floppies, N=20 is more than enough; I don't have
the values for the rarely used 2.88MB size (and I don't think the drives
in the s700 handle that size anyway). This header magic should be copied
off an honest-to-goodness PC floppy once with the command

# dd if=/dev/rfloppy of=/a/good/place/to/store/the/header bs=512 \
count=20

and then written back to each "cloned" floppy with the same command,
reversing "if" and "of". (Slightly faster performance is possible using
the variant:

# dd of=/dev/rfloppy if=/the/copied/header ibs=512 count=20 obs=9k \
conv=sync

This causes floppy I/O to be done in multiples of 9kB, i.e. one cylinder
at a time.)

You should of course have two such headers, one for 720kB and one for
1.44MB floppies: lying to MS-DOS or the dos* utilities about the floppy
capacity would be a bad idea. If you're writing a script to automate
all this, you can determine the capacity of a floppy loaded in the drive
using the following fragment of Korn shell:

kbsize=$( diskinfo -b /dev/rfloppy 2>/dev/null )
if (( $? != 0 || $kbsize == 0 )) ; then
print -u2 "$0: Wot, no media!?"
rm -f core # 9.01s700 diskinfo coredumps
exit 1
fi



UNIXguide.net
Suggest a Site