Monthly Columns

All right, what did you do with my floppy drive?

Copyright © 1998 Chris Coleman

When you first come to *BSD from DOS or Windows95/98 the structure of the BSD file system can be a little confusing. The familiar 'c:\' prompt has been replaced with a customizable one, the directory separator '\' has been reversed and there are no 'drive letters' to speak of.

Looking at the computer, it's a generic PC, complete with IDE hard drives and a 3 1/2" floppy drive. The floppy drive is right there, you can see it. You search in vain, but the funky little blinking prompt will not be persuaded to reveal the whereabouts of your 'A:\' drive.

It's driving you nuts. You search the online man pages, apropos, and even whatis, still nothing. Finally you scream. "HOW DO I ACCESS MY (expletives deleted) A:\ DRIVE!!!!!". You look at the computer, but still it just sits there in silence.

Understanding how to access the floppy disk can be simple when you understand the bigger picture of how the filesystem is integrated into BSD.

PRINCIPLES COVERED:

THE BSD DIRECTORY TREE:

Directories make up the structure of the BSD filesystem. Directories are delimited by the '/' character, and may contain files or other directories. Each directory has a unique name, consisting of its name plus its parent directories, called a PATH. To see your current path, type 'pwd'. In Win95, directories are called 'Folders'.

The description so far is pretty dry and you might wonder how this is different from DOS or Win95. At this level it's not, the DOS filesystem is patterned after UNIX (aside from the reversed '\'). Most directory commands work the same on both systems, such as 'cd' or 'mkdir' and 'rmdir'.

The real difference comes when you add a 2nd hard drive, or partition an existing one. DOS makes you turn any partitions you create into logical drives. Additional DOS drives are always given drive letters. In BSD all data storage media, including removable media such as floppy disks and CDROMs, must be incorporated into the existing directory structure. The BSD term for this, and hence the command name, is 'mount'.

To mount a filesystem you need to know two things: the mount point and the filesystem device name. The mount point is any existing directory in your filesystem that the floppy disk will attach to. Any information contained on the floppy will become available in the directory.

If the directory you choose as the mount point already contains files or sub-directories, they will be "covered up" and will not be available while the disk is mounted. Unmounting the disk will make the information available again.

The directory '/mnt' is often used as a temporary mount point. You might also want to create a separate mount point directory for your floppy disk.

BSD DEVICES:

Devices are represented as files in a directory called /dev. If you watch the boot messages, or type dmesg to review the boot messages, you will see the names of the floppy disk devices. The following three lines are from the boot messages:

        fdc0 at 0x3f0-0x3f7 irq 6 drq 2 on isa
        fdc0: FIFO enabled, 8 bytes threshold
        fd0: 1.44MB 3.5in

fdc is the Floppy Disk Controller and fd is the Floppy Disk Drive. These devices are numbered starting at zero. If you type: 'ls -d /dev/fd*' you will get

/dev/fd         /dev/fd0.1480   /dev/fd0.800    /dev/fd0c       /dev/fd0g       /dev/fd1.1440   /dev/fd1.720    /dev/fd1b       /dev/fd1f
/dev/fd0        /dev/fd0.1720   /dev/fd0.820    /dev/fd0d       /dev/fd0h       /dev/fd1.1480   /dev/fd1.800    /dev/fd1c       /dev/fd1g
/dev/fd0.1200   /dev/fd0.360    /dev/fd0a       /dev/fd0e       /dev/fd1        /dev/fd1.1720   /dev/fd1.820    /dev/fd1d       /dev/fd1h
/dev/fd0.1440   /dev/fd0.720    /dev/fd0b       /dev/fd0f       /dev/fd1.1200   /dev/fd1.360    /dev/fd1a       /dev/fd1e

Some of the devices have sizes after them, these refer to the density and formatting of the disk. Other devices have letters appended to them, these refer to sub-partitioning that can occur on disk drives. Normally only hard disks have sub-partitioning, however floppy disks follow the same rules and the same meanings apply.

Just for reference the letters are as follows:

HOW TO ACCESS THE FLOPPY:

Mounting a floppy disk may require 'root', or SuperUser access. This is because you need 'write' permission to both the mount point and the device being mounted. By default general users don't have write permission to /dev/fd0

To mount a BSD formatted floppy to a directory called '/mnt' you would type:

mount /dev/fd0 /mnt

**(/dev/fd0 implies that the disk is 1.44 meg in size and that you want to access the whole disk.)**

Then cd to /mnt and the contents of the floppy disk will be available.

If you have a MSDOS disk that you want access to, you can use the command:

mount -t msdos /dev/fd0 /mnt

FreeBSD has an easy to remember command to do the same thing: mount_msdos You can type:

mount_msdos /dev/fd0 /mnt

To check and see if it mounted you can cd to the directory and type 'ls' and see if the contents have changed.

By typing 'df' you will see a list of all the file systems that are currently mounted and where they are mounted to. It will also show the amount of space used.

        Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
        /dev/sd0s1a     49583    21216    24401    47%    /
        /dev/sd0s1g   2266664  1834586   250745    88%    /usr
        /dev/sd0s1e     49583     7194    38423    16%    /var
        /dev/sd0s1f   1488607    14400  1355119     1%    /var/mail
        /dev/ccd0c    8234763    56834  7519148     1%    /usr/home
        procfs              4        4        0   100%    /proc
        /dev/fd0         1423       17     1406     1%    /mnt

The last line shows the floppy device (/dev/fd0) mounted on /mnt.

Mounting a MSDOS floppy would give you access to the floppy just like a regular directory on the system, however it will automatically truncate the file names of any files copied to that directory to the DOS 8.3 notation. (ie. FreeBSD.File.long.name will become FreeBSD.Fil)

Newer versions of *BSD now have support for long DOS/Win95/98 filenames.

When you are done with the floppy disk, you will have to unmount it from the file system. To do this type:

umount /dev/fd0

OR

umount /mnt

Either one will successfully unmount the file system. You cannot unmount a file system while you are in the directory that the filesystem is mounted to. This will give you a device busy error. You will have to cd out of that directory before unmounting it. Note the name of the command is 'umount' and not 'unmount' -- this is often a source of frustration with new users of *BSD.

Now when you cd to /mnt it should be empty.

Now you should be able to mount a BSD or MSDOS formatted floppy disk. The same principles that apply to floppy disks, apply to all removable media, including CDROMs, Zip Disks, LS120 disks and so forth.

Chris Coleman chrisc@vmunix.com