Clever website slogan
Home > Tech > Linux

Basic Use of a Floppy Disk in Linux

The first step is knowing where to find the floppy drive on your system. In many cases it is /dev/fd0 but, checking your file system table (fstab) will help you to be sure.

Fstab is typically located in /etc/fstab but, you can search for it using the find command:

find / -type f -name fstab

Now that you know where it is, see what the fstab reads:

cat /etc/fstab

The ubuntu box I'm on today included the line below:

/dev/fd0 /media/floppy auto rw,user,noauto,exec,utf8 0 0

Today we are only concerned with the first three fields but, here is a brief listing of what they tells us:

Device location: /dev/fd0
Mounted read/write point: /media/floppy
File System Type: auto
Mount Options: rw,user,noauto,exec,utf8
File system dump frequency: 0
File system check frequency: 0

The first field, /dev/fd0, tells us the device location. To format your floppy for use in linux, while deleting everything on the disk, insert the floppy disk and run the following command:

mkfs -t ext3 /dev/fd0 1440

The second field, /media/floppy, tells us the default read/write location for files once the disk is mounted (/mnt/floppy is also popular). You are not required to use the default mount point and you may create and use any directory that you'd like for your mount point.

mkdir /media/floppy

The third field, "auto", tells us that the kernel will attempt to automatically detect and use the appropiate filesystem for the floppy.


Finally, ensure your floppy disk in the drive and mount it:

mount /dev/fd0 /media/floppy

If you are using the defaults in fstab, you can shorten this down to:

mount /media/floppy

What if your floppy was originally formatted on a Windows computer and contains files from Windows on it?

If your third column in /etc/fstab, that is, your file system type is: auto, it shouldn't matter. The auto means you will be able to read whatever file system type is on your floppy. You should be able to view plain text from Windows just as if it had been written on Linux. You might need to run dos2unix on your text files to remove the extra carriage return character used by DOS. However, if your file system type listed ext2, or if you are having difficulty reading text files from Windows, try this as your mount command:

mount -t vfat /dev/fd0 /media/floppy

Reading / Writing

Not that the floppy has been mounted you should be able to read and write files just like with any other directory on your system.

To list files on the floppy:

ls /media/floppy

To copy a file to the floppy:

cp myfile /media/floppy/

To show the contents of a text file on the floppy:

cat /media/floppy/myfile

Unmounting (IMPORTANT)

Everytime you switch floppy disks, you will need to unmount your previous files and mount the file system from your new floppy. The umount command is used for unmounting. In addition to unmounting, the umount command also "flushes the buffers" so that whatever you wrote to your floppy really does get written there (similar to thumb drives).

umount /media/floppy

To learn more about fstab and mounting run "man fstab" and "man mount"