Linux – Host system keyboard layout changes when starting LXC container

keyboard-layoutlinuxlxc

I successfully created an archlinux container on an archlinux host with lxc. However, whenever I start a container via

    lxc-start -n GUESTNAME

the keyboard layout changes to the default us-layout on the host and in the container. But I want it to be de-latin1. What is surprising is that this keeps happening despite the fact that in

    /etc/vconsole.conf

on the host and in the container I have set the options

    KEYMAP=de-latin1

The cause of this problem seems to be that the systemd service responsible for setting the vconsole options is not running inside the container:

            systemctl status systemd-vconsole-setup
     ● systemd-vconsole-setup.service - Setup Virtual Console
       Loaded: loaded (/usr/lib/systemd/system/systemd-vconsole-setup.service; static)
       Active: inactive (dead)
               start condition failed at Mon 2014-06-02 20:53:10 UTC; 27s ago
               ConditionPathExists=/dev/tty0 was not met
         Docs: man:systemd-vconsole-setup.service(8)
               man:vconsole.conf(5)

Somehow it states that

    /dev/tty0 was not met

but I am unsure what it is trying to tell me. The archlinux linux containers page (https://wiki.archlinux.org/index.php/Linux_Containers#Terminal_settings) is not helping me. Can someone please explain the error and how to solve it?


UPDATE:

(1) The keyboard layout does not change when I start the container directly from the console (e.g. by starting tmux tmux new -s stoic then running sudo lxc-start -n stoic and then detaching from the tmux session via CTRL-a-d) i.e. before logging into X.

This points to another possible explanation: When I log into X the keyboard layout gets set by my .xinitrc which has the content:

    setxkbmap -model pc105 -layout de -variant ,qwertz -option lv3:caps_switch
    if [ -s ~/.Xmodmap ]; then
        xmodmap ~/.Xmodmap
    fi
    [[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources

If I then run a container via sudo lxc-start -n stoic within X it will also boot to the console and not to X (that’s the way I set up all my systems). Hence, it resets the keyboard layout I guess. But this wouldn’t be that big a problem if the container would at least respect the aformentioned /etc/vconsole.conf.

(2) I use a privileged container.

(3) Here is my current config-file:

    lxc.utsname=stoic
    lxc.autodev=1
    lxc.tty=1
    lxc.pts=1024
    lxc.mount=/var/lib/lxc/stoic/fstab
    lxc.cap.drop=sys_module mac_admin mac_override sys_time
    lxc.kmsg=0
    lxc.stopsignal=SIGRTMIN+4
    #networking
    lxc.network.type=veth
    lxc.network.link=br0
    lxc.network.flags=up
    lxc.network.name=eth0 
    lxc.network.mtu=1500
    #cgroups
    lxc.cgroup.devices.deny = a
    lxc.cgroup.devices.allow = c *:* m
    lxc.cgroup.devices.allow = b *:* m
    lxc.cgroup.devices.allow = c 1:3 rwm
    lxc.cgroup.devices.allow = c 1:5 rwm
    lxc.cgroup.devices.allow = c 1:7 rwm
    lxc.cgroup.devices.allow = c 1:8 rwm
    lxc.cgroup.devices.allow = c 1:9 rwm
    lxc.cgroup.devices.allow = c 4:1 rwm
    lxc.cgroup.devices.allow = c 5:0 rwm
    lxc.cgroup.devices.allow = c 5:1 rwm
    lxc.cgroup.devices.allow = c 5:2 rwm
    lxc.cgroup.devices.allow = c 136:* rwm
    lxc.rootfs = /var/lib/lxc/stoic/rootfs
    lxc.pts = 1024

Best Answer

This has been fixed in releases of lxc >= 1.1 with the introduction of the fuse-filesystem lxcfs. Simply install and set up lxc with lxcfs.

Related Question