No network in chroot environment

Ralf Mardorf silver.bullet at zoho.com
Sat Jan 25 20:54:03 UTC 2020


On Sat, 25 Jan 2020 21:43:53 +0100, Ralf Mardorf wrote:
>To workaround issues when using systemd-nspawn without the -b option my
>resolv.conf files are files and not links. IIRC a link does work, when
>using systemd-nspawn with the -b option. However, while a chroot allows
>to do some things, that still can't be done by using
>systemd-nspawn, with or without the -b flag, a chroot might suffer from
>one or another pitfall (perhaps related to systemd). Perhaps
>resolv.conf is such a pitfall.
>
>There's no issue at all by using a resolv.conf file instead of a link
>for my Ubuntu 16.04 and Arch Linux installs, at least not when using
>systemd-nspawn.
>
>Sometimes systemd-nspawn can't replace a chroot. However, I didn't
>remember any issue by using resolv.conf files instead of links, when
>using a chroot, but maybe resolv.conf wasn't needed at all, when I
>needed to use a chroot instead of systemd-nspawn.
>
>Consider to dally over with the principle of trial and error. IOW for
>testing purpose replace the links by a file.

PS:

And the files instead of links are no issue at all, too, when using my
Ubuntu or Arch install by just booting it from bare metal, instead of
chrooting or systemd-nspawning it ;).

[rocketmouse at archlinux ~]$ llmount -w moonstudio
[sudo] password for rocketmouse: 
[rocketmouse at archlinux ~]$ su
Password: 
[root at archlinux rocketmouse]# cd /mnt/moonstudio/
[root at archlinux moonstudio]# lsb_release -a
LSB Version:	1.4
Distributor ID:	Arch
Description:	Arch Linux
Release:	rolling
Codename:	n/a
[root at archlinux moonstudio]# ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 94 Jan 22 04:32 /etc/resolv.conf
[root at archlinux moonstudio]# systemd-nspawn lsb_release -a
Spawning container moonstudio on /mnt/moonstudio.
Press ^] three times within 1s to kill container.
LSB Version:	core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial
Container moonstudio exited successfully.
[root at archlinux moonstudio]# systemd-nspawn ls -l /etc/resolv.conf
Spawning container moonstudio on /mnt/moonstudio.
Press ^] three times within 1s to kill container.
-rw-r--r-- 1 root root 94 Jan 22 04:32 /etc/resolv.conf
Container moonstudio exited successfully.
[root at archlinux moonstudio]# ls -l /mnt/moonstudio/etc/resolv.conf
-rw-r--r-- 1 root root 94 Jan 22 04:32 /mnt/moonstudio/etc/resolv.conf
[root at archlinux moonstudio]#







More information about the ubuntu-users mailing list