mikma / lxd-openwrt

Scripts for building LXD images from OpenWrt rootfs tarballs.
MIT License
150 stars 39 forks source link

How to create additional /dev nodes? #19

Closed twisteroidambassador closed 4 years ago

twisteroidambassador commented 4 years ago

I have built an OpenWRT 18.06.5 template from this repo, and successfully created a container in Proxmox 6.1. Out of the box, PPPoE does not work, giving an error of "NO_KERNEL_SUPPORT". To fix this, I loaded the pppoe kernel module on the host, added the corresponding cgroup entry in the config file, and ran mknod /dev/ppp c 108 0 inside the container. This allowed PPPoE to work correctly, but after rebooting, the device file is no longer there, and I have to rerun the mknod command by hand.

What is the proper way to add this device file automatically on boot? I tried, but haven't found what is responsible for creating device nodes in the container.

I imagine I can simply create a script in /etc/init.d, but is there a more "official" way?

twisteroidambassador commented 4 years ago

On further research, it seems like the /dev directory inside the container is created by lxc.autodev. I have not found an explicit setting of this option in the container config file, but the man page implies that lxc.autodev = 1 is default.

The man page also suggests using lxc.hook.autodev to help populate /dev. On the other hand, the lxc bug ticket here suggests using lxc.mount.entry to bind mount the host's /dev/ppp into the container. Looks like these two methods are the "canonical" way to add /dev nodes.

mikma commented 4 years ago

The "canonical" way to add a /dev node to lxd seems to be using lxc config device. I haven't tried if pppoe works, but the following line at least creates the /dev/ppp. lxc config device add <container> ppp-device unix-char path=/dev/ppp