I’ll leave this here if someone is interested in this. I had to spend some time to figure all this out so it might save somebody’s time:

So I found this old PC with a real native floppy interface (i.e. not USB floppy drives) and I wanted to use Linux to image and low-level format old disks more conveniently than in DOS or Windows.

The problem is, modern Linux kernels have dropped support for low-level floppy controller commands (i.e. the FDRAWCMD ioctl) in the floppy module: the ioctl has always been problematic and it was finally dropped in April 2022.

That means you can’t do anything but basic generic block device operations on floppies on a modern Linux distribution. So things like dd and basic mtools commands like mdir or mtype. That’s fine if your floppies have a standard format and are in good working condition. For anything else though, you’re SOL.

I had already installed the 32-bit version of Debian 12 Bookworm on my old PC, which is the most modern version of i686 Linux you can find at the moment, and I had it all configured nicely. So I wasn’t exactly keen on regressing to an older distro until I found one with full native floppy support - not to mention the PITA of downloading and trying progressively older distros until I found one.

So I simply regressed the kernel and finally found the last one that still has FDRAWCMD support enabled:

~$ uname -srv
Linux 4.19.0-20-686-pae #1 SMP Debian 4.19.235-1 (2022-03-17)

To install this kernel, do this:

  • Add the Debian 10 (aka Buster) repo to your APT sources.list:

    sudo bash -c "echo deb http://ftp.debian.org/debian buster main >> /etc/apt/sources.list"

  • Update the cache:

    sudo apt update

  • Install the older kernel (this assumes that you’re on a 32-bit machine of course):

    sudo apt install linux-image-4.19.0-20-686-pae

  • Reboot, go into the Grub menu and select the 4.19 kernel after the POST.

  • Once the machine has rebooted, confirm that the 4.19 kernel is running:

    uname -v

If you haven’t done it yet, install common floppy tools:

sudo apt install mtools
sudo apt install fdutils

Also add youself to the disk group to have access to the floppy interfaces as a user, not just as root:

sudo useradd -G disk your_username

To confirm that low-level floppy access is functional, insert a floppy you don’t care about in the drive corresponding to A: in DOS and do:

superformat /dev/fd0 --superverify

You should see something like this (here it didn’t work, I used a floppy with bad sectors for the sake of example):

~$ superformat /dev/fd0 --superverify
Measuring drive 0's raw capacity
In order to avoid this time consuming measurement in the future,
add the following line to /etc/driveprm:
drive0: deviation=-480
CAUTION: The line is drive and controller specific, so it should be
removed before installing a new drive 0 or floppy controller.

 Verifying cylinder 15, head 1 error during command execution
   66 04 0f 01 01 02 12 1b ff 
44 20 20 0f 01 01 02 
CRC error in data field
CRC error in data or address
cylinder=15 head=1 sector=1 size=2
error during command execution
   66 04 0f 01 01 02 12 1b ff 
44 20 20 0f 01 01 02 
CRC error in data field
CRC error in data or address
cylinder=15 head=1 sector=1 size=2
 Verifying cylinder 15, head 1 error during command execution
   66 04 0f 01 01 02 12 1b ff 
44 20 20 0f 01 01 02 
CRC error in data field
CRC error in data or address
cylinder=15 head=1 sector=1 size=2
error during command execution
   66 04 0f 01 01 02 12 1b ff 
44 20 20 0f 01 01 02 
CRC error in data field
CRC error in data or address
cylinder=15 head=1 sector=1 size=2

And as a reminder, here are a few useful commands for direct floppy access in Linux (without mounting the device):

  • List the content of a floppy DOS-stylee:
~$ mdir a:
 Volume in drive A has no label
 Volume Serial Number is 2819-14E6
Directory for A:/

COMMAND  COM     93040 2005-04-18  17:54 
DISPLAY  SYS     17175 2005-04-18  17:54 
EGA      CPI     58870 2005-04-18  17:54 
EGA2     CPI     58870 2005-04-18  17:54 
EGA3     CPI     58753 2005-04-18  17:54 
KEYB     COM     21607 2005-04-18   3:04 
KEYBOARD SYS     34566 2005-04-18  17:54 
KEYBRD2  SYS     31942 2005-04-18  17:54 
KEYBRD3  SYS     31633 2005-04-18  17:54 
KEYBRD4  SYS     13014 2005-04-18  17:54 
MODE     COM     29239 2005-04-18  17:54 
AUTOEXEC BAT         0 2012-10-15  17:46 
CONFIG   SYS         0 2012-10-15  17:46 
       13 files             448 709 bytes
                            889 344 bytes free
  • Dump the entire floppy raw in an image file:
~$ dd if=/dev/fd0 of=floppy.img
2880+0 records in
2880+0 records out
1474560 bytes (1.5 MB, 1.4 MiB) copied, 50.8244 s, 29.0 kB/s
  • List the content of the floppy image file as if it was a real floppy:
~$ mdir :: -i floppy.img 
 Volume in drive : has no label
 Volume Serial Number is 2819-14E6
Directory for ::/

No files
                          1 457 664 bytes free
  • Copy a file to/from a floppy:
~$ mcopy test.txt a:
~$ mcopy a:test.txt .
  • Dump a file on the floppy on the console like DOS’ TYPE would:
~$ mtype a:test.txt

Complete list of mtools utilities:

~$ mtools
Supported commands:
mattrib, mbadblocks, mcat, mcd, mclasserase, mcopy, mdel, mdeltree
mdir, mdoctorfat, mdu, mformat, minfo, mlabel, mmd, mmount
mpartition, mrd, mread, mmove, mren, mshowfat, mshortname, mtoolstest
mtype, mwrite, mzip

Complete list of fdutils utilities:

~$ dpkg -L fdutils | awk '{FS="/"} /bin\/[a-z]/ {print $4}'
diskd
diskseekd
fdmount
fdrawcmd
floppycontrol
floppymeter
getfdprm
setfdprm
superformat
xdfcopy
fdutilsconfig
fdlist
fdmountd
fdumount
xdfformat

I hope this helps.

  • sqw
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 day ago

    I pray this thread persists for the next person who needs this info.