No network in chroot environment

Volker Wysk post at volker-wysk.de
Sat Jan 25 20:35:17 UTC 2020


Am Samstag, den 25.01.2020, 21:05 +0100 schrieb Tom H:
> On Sat, Jan 25, 2020 at 1:20 PM Volker Wysk <post at volker-wysk.de>
> wrote:
> 
> 
> > > > > One option might be to copy "/run/.../resolv.conf" to the
> > > > > chroot
> > > > > before chrooting.
> > > > 
> > > > This sounds like a hack.
> > > 
> > > Before "/etc/resolv.conf" was a symlink, you'd copy
> > > "/etc/resolv.conf"
> > > to "$mountpoint/etc/resolv.conf". You can call it a hack, but
> > > it's
> > > what's needed to ensure name resolution.
> > 
> > I've thought about it, and found that there is no clean way to do
> > it.
> > The (chrooted) child system is "dead". It's in the state after the
> > last shutdown. But the commands which are to be executed, need an
> > "alife" system. For instance, the resolver must be operational for
> > calling "apt update".
> 
> # ls -l "$mountpoint"/etc/resolv.conf
> { it'll be a symlink to one of }
> /run/NetworkManager/resolv.conf
> /run/resolvconf/resolv.conf
> /run/systemd/resolve/stub-resolv.conf
> /run/systemd/resolve/resolv.conf
> { AFAIK, by default, it'll be to /run/systemd/resolve/stub-
> resolv.conf }
> 
> # mkdir -p "$mountpoint"/run/systemd/resolve
> 
> # cp -L /etc/resolv.conf run/systemd/resolve/stub-resolv.conf

It looks like I have to do it this way, if I can't figure out how to do
it with a slave mount, or private mount, of the /run directory...

> But, if the chrooting and chrooted systems use the same resolv.conf
> managejment system, bind-mounting "/run" should take care of chrooted
> symlink - and the "cp ..." will fail.

I don't want the chrooted system to mess with the /run of the parent
system, which is on the USB-stick, which I'm using. Bind-mounting /run,
without --make-(r)slave, would propagate everything from the chrooted
system to the parent system. In the end, both might get broken.


Bye,
Volker





More information about the ubuntu-users mailing list