2014-06-18

HOWTO: reload mouse driver in Linux

Sometimes your mouse device (it can be even a touchpad or a trackball) can unexpectedly get stuck [maybe it's a new bug that should be reported?!] in the middle of your work (or maybe it just didn't get recognized after plugging/unplugging/replugging it in).
In such cases, reloading the mouse driver may help (e. g., for PS/2 mouse driver, Linux kernel module is called "psmouse"):
# modprobe -r -v psmouse
# modprobe -v psmouse
You can also get info on any kernel driver modules installed in your system to support different mouse types (e. g., for serial mice, the kernel module is called "sermouse"), and also check if it's currently loaded:
$ ls /lib/modules/$(uname -r)/kernel/drivers/input/mouse
...  sermouse.ko  ...
$ /sbin/modinfo sermouse
...
$ lsmod | grep sermouse
...
Notes:
  1. you can check the dmesg log for any strange symptoms:
    $ dmesg | grep psmouse
    ...
    [    9.0123456] psmouse ... lost synchronization, throwing 2 bytes away.
  2. the trick will fail if the needed kernel module is built-in (probably only reboot can help);
  3. sometimes it's some X11 driver which causes problems (please check /var/log/Xorg.0.log);
  4. if you use your mouse in console mode, perhaps it's good to check the post about gpm.
---
Last updated: 2016-05-20

2014-06-10

HOWTO: work around SATA HDD hotplug problem (in Linux)

Sometimes some SATA controllers do not recognize an attached HDD if it was hot-plugged after the Linux system has been booted. Fortunately, there're some simple workarounds (note: it should work for some PATA controllers too).
  1. A standard "soft" solution (should work by default):
    1. Connect the HDD to the SATA controller (and make sure it doesn't get auto-recognized by the system).
    2. Force a rescan of SCSI buses:
      # for h in /sys/class/scsi_host/host*/scan; do echo "- - -" > $h; done
    3. Ensure the drive has been recognized (check the dmesg logs, run lsblk etc.) and enjoy it!
  2. A more "aggressive" method
    (note: some old SATA controller made by VIA Technologies and managed by sata_via kernel driver is used here for sample purposes; should work with any recent 2.6+ Linux kernel versions):
    1. To prevent any data loss, flush caches & unmount all the mounted partitions for all the drives connected to any VIA SATA controller(s) installed on the affected system!
    2. Remove the kernel driver module (verbosity is helpful sometimes):
      # modprobe -v -r sata_via
    3. Physically attach (or detach) any drives to the VIA SATA controller.
    4. Re-insert the kernel module:
      # modprobe -v sata_via
    5. Enjoy!
References:
  1. Scanning Storage Interconnects - RHEL7 Storage Administration Guide
---
Last updated: 2014-06-20