On Tue, Feb 7, 2017 at 2:54 PM, Walter Dnes <waltd...@waltdnes.org> wrote: > > Any idea how to gracefully handle the missing /dev problem? I tried > mounting /dev, /proc, and /sys, similar to the chroot process in the > Gentoo install instructions. But I couldn't unmount afterwards, short > of rebooting. If it's not a problem, I'm OK with the mounts sticking > around permanently. >
Did setting up those mounts actually work? They should have. As far as unmounting goes, the handbook instructions recursively set up some mounts so you need to unmount stuff like /dev/pts before umounting /dev (and there might be other examples, I'm going from memory here). This is one of the reasons I like containers. When the last process exits, all this stuff goes away. I suspect sticking something like this before the chroot command might do the trick: unshare -p -f --mount-proc -m -i -u That will create a new PID, mount, IPC, and UTS namespace for the chroot. If you do the mounts after this then when the process exists any mounts will disappear. If you run ps -ea inside you'll see your shell running as pid 1. Now, if you set up your mounts before running unshare then they'll stick around since they were set up in the host namespace and not the container. Most tools for containers like nspawn/docker/lxc/etc will take care of this sort of thing for you. Unshare just exposes the system call without doing any of the setup for you (it is part of util-linux). -- Rich