How do I access floppies under Linux?

(written by Haidinger Walter)

By mounting. First you need a mount-point, i.e. a directory under which you can access your floppy. You can chose an arbitrary name, I use /df0 through /df3 (and /pc0 to /pc3 respectively) because I'm used to these names from AmigaOS.

Create the directories. e.g.:

mkdir /df0
mkdir /any-name-will-do
mkdir /ados/df0
mkdir /ados/pc0
    ...

Next, check if you have the proper device nodes: Type:
ls -l /dev | grep "^b.* 2,   [0-7]"

For me, that lists:

   brw-r--r--   1 root     wheel      2,   0 Mar 31 18:16 df0
   brw-r--r--   1 root     wheel      2,   1 Mar 31 18:16 df1
   brw-r--r--   1 root     wheel      2,   2 Mar 31 18:16 df2
   brw-r--r--   1 root     wheel      2,   3 Mar 31 18:16 df3
   brw-r-----   1 root     25         2,   0 Jun 22  1996 fd0-
   brw-r-----   1 root     25         2,   4 Feb 26  1994 fd0d360
   brw-r-----   1 root     25         2,   4 Jun 22  1996 fd0d360-
   brw-r-----   1 root     25         2,   5 Jun 22  1996 fd1d360
   brw-r--r--   1 root     wheel      2,   4 Apr  4 11:49 mfd0
   brw-r--r--   1 root     wheel      2,   5 Apr  4 11:49 mfd1
   brw-r--r--   1 root     wheel      2,   6 Apr  4 11:49 mfd2
   brw-r--r--   1 root     wheel      2,   7 Apr  4 11:49 mfd3
   brw-r--r--   1 root     wheel      2,   4 Mar 31 18:03 pc0
   brw-r--r--   1 root     wheel      2,   5 Mar 31 18:16 pc1
   brw-r--r--   1 root     wheel      2,   6 Apr  8 12:03 pc2
   brw-r--r--   1 root     wheel      2,   7 Apr  8 12:03 pc3

   ^                                  ^    ^       =09  ^^^
   block-device                    major  minor           node-name=20

Do not worry if you have other results. What do you need to know?

Now create the device-nodes:

mknod /dev/df0 b 2 0
mknod /dev/df1 b 2 1
mknod /dev/df2 b 2 2
mknod /dev/df3 b 2 3

mknod /dev/pc0 b 2 4
mknod /dev/pc1 b 2 5
mknod /dev/pc2 b 2 6
mknod /dev/pc3 b 2 7

Set the desired permissions with the chmod command.

Remember, the names (here: df0 and pc0) are arbitrary. However, on Intel Linux systems, the floppy nodes are named /dev/fd*. To access devices under different node-names, just create symlinks. e.g:

ln -sf /dev/pc0 /dev/fd0
ln -sf /dev/pc1 /dev/fd1
ln -sf /dev/pc2 /dev/fd2
ln -sf /dev/pc3 /dev/fd3

Now, MS-DOS drive 0 can be accessed by /dev/fd0 as well as /dev/pc0. If you want /dev/fd0 to be an Amiga drive, link it to /dev/df0 instead. Of course, this are just examples from my configuration. You can choose other names if you like.

After having mount-point and device-node, you can mount your floppy.

For an AmigaOS disk in drive 0:

mount -t affs /dev/df0 /df0
ls /df0
...
umount /df0

For a MS-DOS disk in drive 1:

mount -t msdos /dev/pc1 /pc1
ls /pc0
...
umount /pc0

Warnings:

You can also put this into your /etc/fstab file. Mine looks like this:

# device        mountpoint      type    options                 freq passno
# --------------------------------------------------------------------------
# Amiga Floppies
/dev/df0        /ados/df0       affs    defaults,noauto,noexec      0 2
/dev/df1        /ados/df1       affs    defaults,noauto,noexec      0 2
/dev/df2        /ados/df2       affs    defaults,noauto,noexec      0 2
/dev/df3        /ados/df3       affs    defaults,noauto,noexec      0 2
#
# MS-DOS Floppies
/dev/pc0        /ados/pc0       msdos   defaults,noauto,noexec      0 2
/dev/pc1        /ados/pc1       msdos   defaults,noauto,noexec      0 2
/dev/pc2        /ados/pc2       msdos   defaults,noauto,noexec      0 2
/dev/pc3        /ados/pc3       msdos   defaults,noauto,noexec      0 2

I'm not quite sure about the freq/passno fields. Do a "man 5 fstab" and a "man 8 mount" for more info.

Other topics about floppies:

mtools

You can use the "mtools" package to access MS-DOS disks without the need of mount/umount. The mtools-3.6.tar.gz package compiled without any problems out of the box for me. The nodes /dev/fd0 and /dev/fd1 are used to access the MS-DOS drives. If you followed my descriptions above it is not necessary to edit mtools.conf (in /etc or /usr/local/etc)

formatting

Hhm. Good question. There are some binaries in bin/system/floppy at ftp.uni-erlangen.de. Unfortunately for me, fdformat dies with a segmentation fault and amifdformat-formatted disks can't be mounted using affs. Any suggestions are welcome!