# keyboard layout in single-user boot mode

## sphakka

Hi,

I use OpenRC-0.9.4 and baselayout-2.

I can't manage to log in at single-user boot prompt (maintenance password asked): it looks like my default keyboard layout (IT) is not loaded.

Is there a way to configure a non-US keyboard layout for runlevel S,  without tweaking my inittab? Better off would be having it in GRUB...

Cheers,

  ^s

----------

## tclover

 *sphakka wrote:*   

> I can't manage to log in at single-user boot prompt (maintenance password asked): it looks like my default keyboard layout (IT) is not loaded.

 

Of course it's not loaded if keymap init service is not started. The same is true for consolefont and other init services. If you can boot into boot runlevel, then go ahead and you'll be able to login. 

If ever you have an initramfs with loadable keymap/font at boot time (kernel cmdline or default behaviour of the init script), you could get your keymap/font loaded. Alternatively, if that said initramfs offers a minimal/rescue shell, you could pretty well load manually the keymap/font and then switch root with something like `exec switch_root /newroot /sbin/init 1' to boot to single mode with your it keymap loaded.

NOTE: looak at my signature for such an initramfs that offers all that easily. You can even boot to single/boot, any runlevel with a kernel cmdline as well. Anyway, youu can pretty much add any aditional reasonable tools to it for maintenance purpose, fsck for example.

----------

## sphakka

 *tclover wrote:*   

> If ever you have an initramfs with loadable keymap/font at boot time (kernel cmdline or default behaviour of the init script), you could get your keymap/font loaded.

 

I thought of doing that, but I wonder if there is a more direct way (my PC is a laptop and I don't use any external keyboard). 

I see that loadkeys allows to dump a  'defkeymap' for the kernel sources, so f.i. (found at http://en.gentoo-wiki.com/wiki/TinyGentoo)

```

/usr/src # loadkeys -m /usr/share/keymaps/i386/qwerty/it.map.gz > defkeymap-3.0.6-gentoo.it.c

/usr/src # cp defkeymap-3.0.6-gentoo.it.c linux/drivers/char/defkeymap.c

```

Maybe a bit too radical/hackish... I'll try it, hoping not to screw up anything -- finger crossed  :Wink: 

----------

## sphakka

Hurray, it works!

But the correct location for defkeymap in recent kernels (mine is 3.0.6) is 'drivers/tty/vt/defkeymap.c', thus the correct command sequence is:

```

[ /usr/src/linux # make clean ]

/usr/src/linux # make menuconfig

/usr/src/linux # loadkeys -m /path/to/your.map.gz > drivers/tty/vt/defkeymap.c

/usr/src/linux # make
```

Mind to inject your keymap *after* 'make menuconfig' else it'll overwrite the keymap with the shipped one.

No more keyboard idiosyncrasies at rescue boot, he, he  :Cool: 

As for GRUB, a possible solution is to configure a set of key swaps via 'setkey'. See .f.i http://www.kanotix.com/index.php?module=pnWikka&tag=GrubBootManager.

----------

## sphakka

Argh, a dot sneaked in the link for GRUB conf. It is http://www.kanotix.com/index.php?module=pnWikka&tag=GrubBootManager

----------

## sphakka

Back on this after some misadventure.

As I wrote before, this hack of  building a custom keymap into the kernel  worked fine, until I tried by mistake to load a different keymap ('us') and... damn, *crashed* the kernel   :Rolling Eyes: 

I don't know if that's a kernel bug...

Beware!

----------

## Jaglover

If you boot into single user mode no password is required, just add init=/bin/bash to the kernel command line.

----------

## sphakka

 *Jaglover wrote:*   

> If you boot into single user mode no password is required, just add init=/bin/bash to the kernel command line.

 

Yep, I know that, thanks (and with openrc, rc_shell=/sbin/sulogin should be changed as well, in '/etc/rc.conf'). My problem is that I never managed to use a keyboard with a physical layout that doesn't match the keymap...

Let's say that, instead of the hassle of blindly fiddling with keys + mounting /usr read-only + calling loadkeys, I chose the risk of hacking. I'm quite proud anyway to have found a way of crashing the kernel in a repeatable manner  :Cool: .

----------

## sphakka

BTW, another annoying issue I have is that the keyboard (standard AT, driver compiled into the kernel) doesn't go up immediately after sysinit is started: it takes approximately 20 seconds -- that's also preventing me from using opnerc's interactive feature  :Sad:  I searched around a lot for an explanation but found nothing. Has anybody any idea?

----------

