On Thu, Sep 24, 2015 at 10:18 AM, Tom H <tomh0...@gmail.com> wrote:
>
> You need to ensure that a proper resolv.conf exists in a chroot before
> switching to it. When installing Gentoo, for example, you "cp -L
> /etc/resolv.conf $chroot/etc" before chrooting because the
> installation tarball doesn't have a resolv.conf. I'm sure that if you
> check the Arch installation scripts, you'll find something similar.

The arch-chroot installation script has the following function:

chroot_add_resolv_conf() {
  local chrootdir=$1 resolv_conf=$1/etc/resolv.conf

  # Handle resolv.conf as a symlink to somewhere else.
  if [[ -L $chrootdir/etc/resolv.conf ]]; then
    # readlink(1) should always give us *something* since we know at this point
    # it's a symlink. For simplicity, ignore the case of nested symlinks.
    resolv_conf=$(readlink "$chrootdir/etc/resolv.conf")
    if [[ $resolv_conf = /* ]]; then
      resolv_conf=$chrootdir$resolv_conf
    else
      resolv_conf=$chrootdir/etc/$resolv_conf
    fi

    # ensure file exists to bind mount over
    if [[ ! -f $resolv_conf ]]; then
      install -Dm644 /dev/null "$resolv_conf" || return 1
    fi
  elif [[ ! -e $chrootdir/etc/resolv.conf ]]; then
    # The chroot might not have a resolv.conf.
    return 0
  fi

  chroot_add_mount /etc/resolv.conf "$resolv_conf" --bind
}

So they mount the host's resolv.conf on the chroot's.

And there's the following patch in lxc 0.7.5-3ubuntu69:

# cat 0031-ubuntu-template-resolvconf.patch
Description: handle /etc/resolv.conf being a symlink
 This will be forwarded upstream.
Author: Serge Hallyn <serge.hal...@ubuntu.com>
Forwarded: no
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/922706

Index: lxc/templates/lxc-ubuntu.in
===================================================================
--- lxc.orig/templates/lxc-ubuntu.in 2012-01-27 10:45:16.167886074 -0600
+++ lxc/templates/lxc-ubuntu.in 2012-01-27 10:50:39.567880601 -0600
@@ -389,9 +389,13 @@
             chroot $rootfs apt-get install --force-yes -y
python-software-properties
             chroot $rootfs add-apt-repository ppa:ubuntu-virt/ppa
         fi
-        cp /etc/resolv.conf "${rootfs}/etc"
+ cresolvonf="${rootfs}/etc/resolv.conf"
+ mv $cresolvonf ${cresolvonf}.lxcbak
+        cat /etc/resolv.conf > ${cresolvonf}
         chroot $rootfs apt-get update
         chroot $rootfs apt-get install --force-yes -y lxcguest
+ rm -f ${cresolvonf}
+ mv ${cresolvonf}.lxcbak ${cresolvonf}
     fi
 }

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss

Reply via email to