Suppressing messages in FreeNAS/FreeBSD about unknown USB Devices

I like to run my FreeNAS server on a UPS to make sure that it doesn't die in the middle of some file operation, and can do an orderly shutdown in case of a power failure. I'm also very cheap, so I went down to my local Fry's to find what sort of UPS I could get for a low cost. I ended up buying a CyberPower 645AVR UPS expressly for this purpose. Of course, I made sure to connect the UPS to the FreeNAS box via USB to allow FreeNAS to know when the power is out. Upon doing this, I was able to configure FreeNAS to start up the UPS service, and begin monitoring the UPS status.

Unfortunately, I was noticing messages in my log every few minutes like the following:

Dec 30 14:18:18 xxxx root: Unknown USB device: vendor 0x0764 product 0x0501 bus uhub3

So I did a little digging and found out that FreeBSD, the underlying OS for FreeNAS, uses a service called devd to manage automated actions for USB (and other) device events. After reading up on the man page about the /etc/devd.conf file, I figured I'd write a rule to try and suppress messages for that specific vendor and product id.

Before starting, I knew that because I was running FreeNAS off a USB key I would have to remount the / filesystem so that my changes would be persistent. You can do this at the shell with the following command:

mount -uw /

I added the following to my /etc/devd.conf and /conf/base/etc/devd.conf files, just above the rule that has the action line with the entry to log a message with "Unknown USB device" in the text.

nomatch 10 {
    match "bus" "uhub[0-9]+";
    match "vendor" "0x0764";
    match "product" "0x0501";
};

Finally I needed to remount the / filesystem in read-only mode to make sure my changes were flushed and ready to go next time I booted. Simply issue the following command:

mount -ur /

Remounting may take a while if your USB key is slow like mine. Just be patient and it should finish in a few seconds. The final step is to simply restart the devd service with the following command:

service devd restart

Following these steps suppressed the message and UPS monitoring still seems to be working just fine. Obviously, you need to be careful editing these files, as you may cause important devices not to work properly if you add this entry improperly. This particular rule should be pretty safe, since it should only match a specific vendor and product, and then suppress any action that would normally be executed for that particular device.

Comments

Popular posts from this blog

Using Snapshot Isolation with SQL Server and Hibernate

FreeNAS, CIFS, and user login problems

Official Pandora Desktop and Hotkey Support?