Freebsd – Find when new hardware is connected on FreeBSD

devicesfreebsdhot-plug

How can I find out when a device is connected to my FreeBSD machine? Lets say I plug in a USB device, HDMI device, Bluetooth or something like that.

Can I have a console output to say [device] and gives some output about the device?

Best Answer

All other answers are good, if you want only to check if a device is connected (checking kernel messages with dmesg, check in /var/log files and use some tools like usbconfig, pciconf or camcontrol).

But, if you want more (handle a message and execute a program or something like that when you plug your device), you can use devd.

When you connect a device, FreeBSD kernel will generate messages:

  • when you plug your device, an attach message is generated
  • when you unplug your device, a detach message is generated
  • and more (see devd.conf man page if you want more information).

FreeBSD uses devd by default, and its configuration is stored in /etc/devd/ and /etc/devd.conf. If you use linux, the same features exist with devfs and udev.

You can find some examples in /usr/share/examples/etc/devd.conf.

Related Question