adding line to lxc.conf gives an error

Ronald

New Member
Aug 30, 2016
11
0
1
32
Hello,

When I add the following line to my lxc.conf file, the container wont start.

lxc.hook.autodev = sh -c "modprobe tun; cd ${LXC_ROOTFS_MOUNT}/dev; mkdir net; mknod net/tun c 10 200; chmod 0666 net/tun"

mknod does not work in the container itself as well, not sure what I'm doing wrong, I think it has something to do with the container being a unpriviliged one. Is there someone who can help me?

Thanks in advance,

Ronnie
 
Easiest thing would be this:

Code:
cat > /usr/share/lxc/hooks/lxc-openvpn-net-tun-hook <<'EOF'
#!/bin/sh
cd ${LXC_ROOTFS_MOUNT}/dev
mkdir net
mknod net/tun c 10 200
chmod 0666 net/tun
EOF

chmod +x /usr/share/lxc/hooks/lxc-openvpn-net-tun-hook

and use these settings:

Code:
lxc.cgroup.devices.allow: c 10:200 rwm
lxc.hook.autodev: /usr/share/lxc/hooks/lxc-openvpn-net-tun-hook

Tun has to be loaded in your host, so just add tun to /etc/modules.
 
Thansk for your reply!

I tried that, still gives me the same error.

TASK ERROR: command 'lxc-start -n 175' failed: exit code 1

Where can I find the log files, maybe they spit out something usefull.
 
Thanks again, I get the following:

Code:
 lxc-start 20161218180652.826 ERROR    lxc_conf - conf.c:run_buffer:347 - Script exited wi                                                  th status 1
      lxc-start 20161218180652.826 ERROR    lxc_conf - conf.c:lxc_setup:3824 - failed to run au                                                  todev hooks for container '175'.
      lxc-start 20161218180652.826 ERROR    lxc_start - start.c:do_start:826 - Failed to setup                                                   container "175".
      lxc-start 20161218180652.826 ERROR    lxc_sync - sync.c:__sync_wait:57 - An error occurre                                                  d in another process (expected sequence number 3)
      lxc-start 20161218180652.871 ERROR    lxc_start - start.c:__lxc_start:1357 - Failed to sp                                                  awn container "175".
      lxc-start 20161218180659.575 ERROR    lxc_start_ui - tools/lxc_start.c:main:365 - The con                                                  tainer failed to start.
lxc-start: tools/lxc_start.c: main: 365 The container failed to start.
      lxc-start 20161218180659.575 ERROR    lxc_start_ui - tools/lxc_start.c:main:367 - To get                                                   more details, run the container in foreground mode.
lxc-start: tools/lxc_start.c: main: 367 To get more details, run the container in foreground mo                                                  de.
      lxc-start 20161218180659.575 ERROR    lxc_start_ui - tools/lxc_start.c:main:369
 
This is the output:

Code:
ls -l /usr/share/lxc/hooks/lxc-openvpn-net-tun-hook
-rwxr-xr-x 1 root root 89 Dec 18 14:26 /usr/share/lxc/hooks/lxc-openvpn-net-tun-hook

So I did a chmod 777, just to try if it was something with persmissions, but still the LXC won't start.