Fixing non-responsive usb keyboard on FreeBSD systems

If a FreeBSD 6 or 7 box does not have working USB keyboard while in single user mode the fix is usually to rebuild the kernel with the kbdmux device enabled. In some ISPrime kernel config files this device was left out by mistake.

  1. Discover the kernel config file name
    [root@leaf ~]# uname -a
    FreeBSD leaf.isprime.com 6.2-STABLE FreeBSD 6.2-STABLE #0: Thu Feb 24 17:34:08 EST 2011     root@leaf.isprime.com:/usr/src/sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF  amd64
    [root@leaf ~]#
    
  2. Check the config file and see if it includes any other config. We want to put the kbdmux in the lowest level config file so it will be in the right place for future kernel config changes.
    [root@leaf ~]# cd /sys/amd64/conf
    [root@leaf /sys/amd64/conf]# cat ISPRIME1950-64BITRAID-SMP-LEAF
    #
    # we have more than 10G of memory we can set maxusers much higher than
    # the default 384 -bw- 2011-02-24
    #
    maxusers 4096
    include ISPRIME1950-64BITRAID
    
    options SMP
    [root@leaf /sys/amd64/conf]# 
    
    The above shows us that we need to look at ISPRIME1950-64BITRAID in the same directory.

  3. Edit ISPRIME1950-64BITRAID and find the devices pertaining to keyboards and usb. Make sure that you see:
    device          usb
    device          ugen
    device          uhid
    device          ukbd            # usb keyboard support
    device          ums
    device		kbdmux		# keyboard multiplexer
    
    If the two commented lines above are not in this lowest level kernel config file add them please. You will of course also need to have basic usb support, but that should be present already.

  4. Now build a new kernel - we will run config against the top level file

    [root@leaf /sys/amd64/conf]# config ISPRIME1950-64BITRAID-SMP-LEAF
    
    Kernel build directory is ../compile/ISPRIME1950-64BITRAID-SMP-LEAF
    Don't forget to do ``make cleandepend; make depend''
    [root@leaf /sys/amd64/conf]# cd ../compile/ISPRIME1950-64BITRAID-SMP-LEAF
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]# make cleandepend && make depend && make
    
    (lots of compiler output skipped)
    
    ===> wlan_tkip (all)
    ===> wlan_wep (all)
    ===> wlan_xauth (all)
    ===> xl (all)
    ===> zlib (all)
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]#
    

  5. Installing the new kernel

    Make a copy of the previous kernel just in case we have a problem. The install process makes a copy in /boot/kernel.old, but if you have 2 bad kernels in a row you might be left without a working kernel, so it is a good idea to keep a known working copy around.

    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]# cp -rp /boot/kernel /boot/kernel-20110404
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]# cp -rp /boot/modules /boot/modules-20110404
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]# make install
    
    (installer output skipped)
    
    install -o root -g wheel -m 555   wlan_wep.ko /boot/kernel
    ===> wlan_xauth (install)
    install -o root -g wheel -m 555   wlan_xauth.ko /boot/kernel
    ===> xl (install)
    install -o root -g wheel -m 555   if_xl.ko /boot/kernel
    ===> zlib (install)
    install -o root -g wheel -m 555   zlib.ko /boot/kernel
    kldxref /boot/kernel
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]#
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]# sync
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]# sync
    [root@leaf /sys/amd64/compile/ISPRIME1950-64BITRAID-SMP-LEAF]# reboot
    

    The system should come up on the new kernel. If it does not the previous kernel is saved and you can boot from it at the loader prompt.