Saturday, January 26, 2013

5.25" Floppy disks in Linux anno 2013

I was having some fun with one of my older machines, an IBM Portable 5155 XT.
I have a large collection of floppies, though some are of cause corrupted by wear and tear and time itself, but surprisingly many of them seem to stand the tests of time quite well.

I wanted to play some of the games I had played on my first computer, Alley Cat, Pac-Man and Sopwith.. However, having lost those floppies, I only had these game on my fileserver, and not on any floppies, so I decided to set out to get them transferred to the machine.
Luckily, it seems Linux is still well-versed in the dark incantations needed for communications with these old floppy-drives.
After a visit to IRC I discovered that one had to make special device-nodes to make non-(3.5" 1.44 MiB)standard drives function properly on Linux

The drive I have is a 5.25" model which takes 1200 KiB 80 track disks, however, the disks I need to feed the IBM are 360 KiB with 40 tracks, of cause the drive hardware has no trouble with this, as soon as Linux understand which drive and disk it is dealing with, this is where the special device nodes comes in.
The automatically (on my Arch dist anyway) /dev/fd0 is a block device with major, minor numbers 2 and 0 (Floppy disk on controller 0, autodetect format), however, according to devices.txt that comes with your Linux kernel, you will find that for reading 360KiB disks in a 1200KiB drive, you need a device node with major, minors of 2 and 20 instead.
Thus the commands to fix all my trouble:
$ mknod /dev/fd0h360 b 2 20
$ mknod /dev/fd0h720 b 2 24
$ mknod /dev/fd0h1200 b 2 8
This allows me to read the 3 kinds of disks that I suspect I have in my collection.

A note on formatting disks.
You might want to install the msdos-utils package.
Formatting from Linux caused me a bit of confusion and manpage digging as it is a two-step process. Assuming the floppy is either unformatted, or have been formatted for another system (such as commodore), it first need to be low-level formattet, if this is not done, mkfs.vfat will write out funny, strange and random error-messages which will have you think that you have a bad floppy or drive.. In short, if mkfs complains, try a lowlevel format.

In the following I will use use my 1200 KiB drive to format 40 track, 360 KiB disks.

Step 1: Lowlevel format using the fdformat tool, plain and simple
$ fdformat /dev/fd0h360

Step 2: Format the disk with the fat12 filesystem:
$ mkfs.vfat -F 12 -I -c -n "DusteDGames" /dev/fd0h360
-F 12 tells that we want the fat 12 filesystem.
-I Tell that there is not supposed to be any partitions on the device.
-c to check for bad blocks before formatting.
-n to name the floppy.

Mounting is no trouble, just remember to unmount your floppies before removing them! ;)