1

I want to format a MF 2HD floppy in a USB floppy disk drive. Since a USB floppy disk drive appears as a da(4) device instead of an fdc(4) device, the standard fdformat utility cannot be used. How can I format my floppy disk?

5

As no formatting program seems to exist, I wrote the following shell script which sends appropriate FORMAT UNIT commands to format all 80 tracks of a floppy disk. The device da0 is formatted unless a different device is supplied as an argument. The CDB has been taken from the UFI specification.

#!/bin/sh

set -e
exec >&2

drive=${1:-da0}
numblocks=2880
blocklen=512
tracks=80
track=0

progress() {
    [ -t 2 ] && printf "\\r%2d/%2d" $track $tracks
}


for track in `seq 0 $((tracks-1))`
do
    progress

    # format bottom
    camcontrol cmd "$drive" -v \
        -c '04 17 i1 00 00 00 00 00 0c 00 00 00' $track \
        -o 12 '00 b0 00 08 i4 00 i3' $numblocks $blocklen

    # format top
    camcontrol cmd "$drive" -v \
        -c '04 17 i1 00 00 00 00 00 0c 00 00 00' $track \
        -o 12 '00 b1 00 08 i4 00 i3' $numblocks $blocklen

done

track=$tracks
progress
[ -t 2 ] && echo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.