Misbehaving Mouse Mended

If you use a KVM switch to move between a PC running Windows and a PC running Linux, you’ve probably encountered Drunken Mouse Syndrome, in which, upon returning to the Linux box, you find your mouse pointer freaks out and behaves wildly, unpredictably, and angrily when you so much as breathe in the direction of your input device. For a long time I assumed that Drunken Mouse Syndrome was the fault of my KVM. Turns out, (1) that’s not true, and (2) there’s a fix.

Drunken Mouse Syndrome only occurs if the mouse that’s connected to the KVM switch is a PS/2 style mouse and there’s a Windows box in the mix. If you’re switching between Linux boxen, you’ll have no case of DMS. The source of the problem, according to some information I found via a particularly grueling session with Google, is the Windows implementation of the PS/2 protocol. Apparently Windows doesn’t take advantage of all the niceties of that protocol, but Linux does—and the way the two OSes differ in their handling of the mouse causes DMS.

If you’re running a 2.4-series kernel, the cure for DMS is simple: Use a Ctrl-Alt-Fn combination to switch to a text console, then Ctrl-Alt-F7 to return to your X Window session. The mouse should be sober.

If you’re running a 2.6-series kernel, you can innoculate your Linux box from DMS entirely, and you’ll never need to do a console flip-flop to restore sanity to your pointer. (In fact, the console flipping doesn’t work on 2.6 machines.) Pass the following parameter to your kernel at boot time:
On my Fedora box, which uses grub for the boot loader, I added this parameter to the appropriate line in /boot/grub/menu.lst. On a machine that uses lilo instead of grub, I believe you’d use an append= line in /etc/lilo.conf to pass the psmouse.proto parameter to the kernel.

[If you’ve found this tip via Googling and it has solved a nagging problem for you, please say so in the comments so I know I’ve helped someone, hmm?]