2

I have a RedHat 7 VM running on VMware ESXi 6 infrastructure. I need to detect a floppy disk insert event and then kickoff a script based on that insert event.

My initial approach was to try and use Udev rules to trigger the script execution on floppy insert, but the event never seems to be kicked off.

/etc/udev/rules.d/99-my.rules

SUBSYSTEM=="block", KERNEL=="fd0", ACTION=="change", RUN+="sh -c /my-custom-script"

When that wouldn't work, I tried to work around the issue and instead of executing on insert, I wrote a cron job that attempts to mount the floppy every couple minutes and tests to see if the mount point has certain files in it. This however, causes some nasty output when there's no floppy disk inserted though:

end_request: I/O error, dev fd0, sector0

So I've found myself trying to figure out why the Udev rule is not working. Is my approach with the Udev rule wrong or is there any other way to achieve this?

  • Does the floppy disk actually mount in RHEL 7, regardless of automatically carrying out actions? – I_GNU_it_all_along Aug 17 '16 at 12:54
  • @ I_GNU_it_all_along The Udev rule file doesn't automatically mount the floppy, but it does mount when done manually. – droche Aug 17 '16 at 12:56
  • Wow, I'm surprised. Sorry I don't have an answer for ya dude, I just needed to check what year it was! Hoperfully someone else can help. – I_GNU_it_all_along Aug 17 '16 at 12:59
  • If its a vm then the only disks it has are emulated ones. Floppy drives ddon't fire an interrupt when a disk is inserted - other block devices do. So why not emulate a different device? – symcbean Aug 26 '16 at 21:44
0

From what I know udev, does not provide any means to monitor floppy drives. Floppy drives do not provide any means to detect insertion i.e. detecting insertion of a disk requires continuous polling of the drive.

The diskd utility does what you need. It continuously polls the drive and exits or executes a command on insertion. It is part of fdutils, which can be installed from the repositories under Debian. Under RHEL/Fedora you will have to compile the sources.

Usage:

diskd [-d drive] [-i interval] [-e command]

The following should monitor the drive for a disk, and on insertion mount it and then exit. I have not tried this, because I only have an IDE Floppy Drive (LS-120 SuperDisk).

diskd -d /dev/fd0 -e "udisks --mount /dev/fd0 --mount-fstype=vfat"

It should be noted that you need to be a member of the floppy group to be able to run this as a non-root-user as it needs direct access to the floppy device (e.g. /dev/fd0). It uses the FDPOLLDRVSTAT ioctl (see man 4 fd) to poll the device.

Also the man-page / documentation has the following warning:

This program works by switching the motor on for a very short interval, and then seeking to track -1. This might damage hardware in the long run. Amigas, which also use these techniques, are known for having problems with their disk drives no longer spinning up properly after a few month of usage.

I am not sure whether this is really a serious problem, but having a spare drive at hand is probably useful if you are going to use this in a production setting. They are no longer that expensive, right?

(The fdmountd utility sounds pretty ancient and I am very skeptical with regards to whether it works with normal FAT12-formatted disks on a "newer" kernel.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.