Solved FreeBSD 11.0-CURRENT Single User Keymap

When compiling a FreeBSD 11.0-CURRENT kernel, what is required to change the keymap used in single user mode?

I have read Thread change-keybord-layout-in-single-user-mode.5528. I have also read the atkbd(4) and ukbd(4) man pages. The relevant parts of my kernel configuration are as follows:

Code:
include GENERIC
ident MY_KERNEL

# AT Keyboard
device          atkbdc
options         ATKBD_DFLT_KEYMAP
makeoptions     ATKBD_DFLT_KEYMAP=jp.106
device          atkbd

# USB Keyboard
device          ukbd
options         UKBD_DFLT_KEYMAP
makeoptions     UKBD_DFLT_KEYMAP=jp.106

# everything else
# ...
So far as I can tell, these options should be working. I am using a 106 key Japanese keyboard. Single user mode appears to use the keymap for a 101 key standard US layout. I have tried the following values:
  • jp
  • jp.106
  • jp.106.kbd (not tried recently)
Finally, this is a FreeBSD VM running in VirtualBox on OSX. I am 99% sure I am having the same problem on my physical machines. The specific driver almost certainly depends on the hardware.
 
What procedure did you use to generate the French layout? /usr/src/sys/dev/kbd/kbdtables.h appears to be an automatically generated file.
 
Was about to link to your other thread where I scanned the man pages and found the above command, but it seems to have just appeared here o_O
 
Single user mode is not a special operating mode so you can start services as you like as long as you pay attention to rcorder(8) order and don't start services that would depend on some service that is not yet running. The /etc/rc.d/syscons service has no dependencies other than the pseudo service LOGIN so you can always do this very early in single user mode (assuming the correct keymap is set in /etc/rc.conf):

service syscons start
 
The service syscons start solution works. It is, however, one more command than I want to type every time I boot into single user mode.

I tried recompiling with the following kernel configuration, but single user mode still boots with a US layout. What are the *KBD*_DFLT_KEYMAP options for?
Code:
# AT Keyboard
device          atkbdc
device          atkbd
options         ATKBD_DFLT_KEYMAP
makeoptions     ATKBD_DFLT_KEYMAP=jp.106

# USB Keyboard
device          ukbd
options         UKBD_DFLT_KEYMAP
makeoptions     UKBD_DFLT_KEYMAP=jp.106

# Sun Keyboard?
device          sunkbd
options         SUNKBD_EMULATE_ATKBD
options         SUNKBD_DFLT_KEYMAP
makeoptions     SUNKBD_DFLT_KEYMAP=jp.106

# Keyboard Multiplexer
device          kbdmux
options         KBDMUX_DFLT_KEYMAP
makeoptions     KBDMUX_DFLT_KEYMAP=jp.106
I am currently recompiling with a manually patched /usr/src/sys/dev/kbd/kbdtables.h. It seems like there ought to be an easier way to do this.
 
Even manually patching /usr/src/sys/dev/kbd/kbdtables.h failed with kbdmux(4) enabled. As implied by PR 194744, disabling kbdmux(4) by adding
Code:
hint.kbdmux.0.disabled="1"
to /boot/device.hints resolved the issue. It is unclear whether the custom keymap is a result of the kernel options or the patched kbdtables.h.

I will try temporarily replacing /usr/share/syscons/keymaps/us.iso.kbd with jp.106.kbd for the build. I want to see if I can get a custom keymap with kbdmux(4) enabled.
 
If you do not want to use the patch provided by PR 194744, the complete workaround is as follows.

First, disable kbdmux(4) by adding the following line to /boot/device.hints.
Code:
hint.kbdmux.0.disabled="1"
Recompile the kernel with the *KBD_DFLT_KEYMAP options using your keymap of choice.
Code:
# AT Keyboard
device          atkbdc
device          atkbd
options         ATKBD_DFLT_KEYMAP
makeoptions     ATKBD_DFLT_KEYMAP=jp.106

# USB Keyboard
device          ukbd
options         UKBD_DFLT_KEYMAP
makeoptions     UKBD_DFLT_KEYMAP=jp.106
In my tests recompiling with a manually patched /usr/src/sys/dev/kbd/kbdtables.h had no impact on kbdmux(4). Neither did replacing /usr/share/syscons/keymaps/us.iso.kbd with another keymap.
 
Back
Top