Mounting a USB Floppy Drive on my Debian Box

This post is a note-to-self.  Well, I had some old files on 3.5″ disks and I wanted to read them, so I got a USB floppy drive — something like this.  Well, exactly like this.  This, in fact:

Fujitsu USB floppy drive.

Fujitsu USB floppy drive.

Fujitsu USB floppy drive.

Also a Fujitsu USB floppy drive.

And I plugged it into my Linux box (current Debian) and… nothing.  Did not show up in any file managers.  I had to mount it manually, so I eventually managed to write a small, clunky script that I can run.  Current version needs sudo, which is not such a big deal for me.

Script (some lines wrapped by WordPress):

# this is mountflop.sh
blkid | grep msdos | cut -d ' ' -f 4 | sed {s/\"//g} - > /home/username/bin/mountflop1

paste /home/username/bin/mountflop? > /home/username/bin/mount_flop

echo "echo Floppy should be mounted on /media/floppy" >> /home/username/bin/mount_flop

sudo bash /home/goossens/bin/mount_flop

Where the files that build the script look like:

$cat mountflop0
::::::::::::::
mount -t msdos
::::::::::::::
$cat mountflop1
::::::::::::::
UUID=4254-18EF
::::::::::::::
$cat mountflop2
::::::::::::::
/media/floppy/

And the generated script winds up looking like:

cat ~/bin/mount_flop
mount -t msdos UUID=1315-0FE3 /media/floppy/
echo Floppy should be mounted on /media/floppy

So blkid finds the identifier that can be used by the mount command.  It finds it by grepping the blkid output for msdos, which identifies the floppy by its file system.  So far I’ve had no problems with this interacting with USB sticks, but maybe it would.  Then I use a simple paste command to assemble my mount command, then bash it.  I know it should all be done with a single file for the script, but this works for me!  I quite like assembling scripts via making little text files — it makes debugging very easy (not that it takes much to debug such a trivial example).  The speed penalty is not significant, and if I want to manipulate a device or a file using a bunch of different such scripts, I can build them from the same little text files, meaning the important labels only need to be changed in one place, which is good for version control.

[[Note, December 2015]] for some reason this has not been working recently, and it was simpler to do this:

I replaced

blkid | grep msdos | cut -d ' ' -f 4 | sed {s/\"//g} -

with

blkid | grep msdos | cut -d ':' -f 1

which ouptuts something like

/dev/sdc

so the mount command uses the dev rather than the UUID.

Oh, and don’t forget to make the mount point and give it any permissions it needs:

/media/floppy

Advertisements

Tags: , , , , , , , , ,

About Darren

I'm a scientist by training, based in Australia.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: