tags 905869 +patch
thanks
Hi,
thanks for the work-around! That way I got the bionic container to get
created.
However, networking wouldn't start, so further changes to the template
are required.
In the end, I extracted the lxc-ubuntu template from the 3.0.3-1 lxc-
templates package and had to do one more change on top of that.
--- /usr/share/lxc/templates/lxc-ubuntu 2018-12-04
08:47:01.000000000 +0100
+++ /usr/share/lxc/templates/lxc-ubuntu 2019-02-05
12:22:59.820862535 +0100
@@ -553,7 +553,7 @@
[ -e "$path/config-auto" ] && cat $path/config-auto >> $path/config
&& rm $path/config-auto
grep -q "^lxc.rootfs.path" $path/config 2>/dev/null || echo
"lxc.rootfs.path = $rootfs" >> $path/config
cat <<EOF >> $path/config
-lxc.uts.name = $name
+lxc.utsname = $name
lxc.arch = $arch
EOF
After that, a bionic LXC container would come up fine on stretch with
networking for me. The full diff for lxc-ubuntu is attached.
michael905...@bugs.debian.org
--
Michael Banck
Projektleiter / Senior Berater
Tel.: +49 2166 9901-171
Fax: +49 2166 9901-100
Email: michael.ba...@credativ.de
credativ GmbH, HRB Mönchengladbach 12080
USt-ID-Nummer: DE204566209
Trompeterallee 108, 41189 Mönchengladbach
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer
Unser Umgang mit personenbezogenen Daten unterliegt
folgenden Bestimmungen: https://www.credativ.de/datenschutz
--- /usr/share/lxc/templates/lxc-ubuntu.orig 2019-02-04 22:40:16.957705157 +0100
+++ /usr/share/lxc/templates/lxc-ubuntu 2019-02-05 12:22:59.820862535 +0100
@@ -92,7 +92,15 @@
password=$5
# configure the network using the dhcp
- cat <<EOF > $rootfs/etc/network/interfaces
+ if chroot $rootfs which netplan >/dev/null 2>&1; then
+ cat <<EOF > $rootfs/etc/netplan/10-lxc.yaml
+network:
+ ethernets:
+ eth0: {dhcp4: true}
+ version: 2
+EOF
+ else
+ cat <<EOF > $rootfs/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
@@ -103,6 +111,7 @@
auto eth0
iface eth0 inet dhcp
EOF
+ fi
# set the hostname
cat <<EOF > $rootfs/etc/hostname
@@ -152,13 +161,20 @@
EOF
chmod +x $rootfs/usr/sbin/policy-rc.d
+ if [ -f "$rootfs/etc/init/ssh.conf" ]; then
+ mv "$rootfs/etc/init/ssh.conf" "$rootfs/etc/init/ssh.conf.disabled"
+ fi
+
rm -f $rootfs/etc/ssh/ssh_host_*key*
- mv $rootfs/etc/init/ssh.conf $rootfs/etc/init/ssh.conf.disabled
+
DPKG_MAINTSCRIPT_PACKAGE=openssh DPKG_MAINTSCRIPT_NAME=postinst chroot $rootfs /var/lib/dpkg/info/openssh-server.postinst configure
- mv $rootfs/etc/init/ssh.conf.disabled $rootfs/etc/init/ssh.conf
sed -i "s/root@$(hostname)/root@$hostname/g" $rootfs/etc/ssh/ssh_host_*.pub
+ if [ -f "$rootfs/etc/init/ssh.conf.disabled" ]; then
+ mv "$rootfs/etc/init/ssh.conf.disabled" "$rootfs/etc/init/ssh.conf"
+ fi
+
rm -f $rootfs/usr/sbin/policy-rc.d
fi
@@ -359,7 +375,13 @@
debootstrap_parameters="$debootstrap_parameters --variant=$variant"
fi
if [ "$variant" = 'minbase' ]; then
- packages_template="${packages_template},sudo,ifupdown,isc-dhcp-client"
+ packages_template="${packages_template},sudo"
+ # Newer releases use netplan, EOL releases not supported
+ case $release in
+ trusty|xenial|zesty)
+ packages_template="${packages_template},ifupdown,isc-dhcp-client"
+ ;;
+ esac
fi
echo "Installing packages in template: ${packages_template}"
@@ -439,7 +461,7 @@
btrfs subvolume snapshot $cache/rootfs-$arch $realrootfs || return 1
[ "$rootfs" = "$realrootfs" ] || mount --bind $realrootfs $rootfs || return 1
else
- rsync -Ha $cache/rootfs-$arch/ $rootfs/ || return 1
+ rsync -SHaAX $cache/rootfs-$arch/ $rootfs/ || return 1
fi
return 0
}
@@ -503,14 +525,14 @@
# if there is exactly one veth network entry, make sure it has an
# associated hwaddr.
- nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
+ nics=`grep -e '^lxc\.net\.0\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
if [ $nics -eq 1 ]; then
- grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config
+ grep -q "^lxc.net.0.hwaddr" $path/config || sed -i -e "/^lxc\.net\.0\.type[ \t]*=[ \t]*veth/a lxc.net.0.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config
fi
# Generate the configuration file
## Relocate all the network config entries
- sed -i -e "/lxc.network/{w ${path}/config-network" -e "d}" $path/config
+ sed -i -e "/lxc.net.0/{w ${path}/config-network" -e "d}" $path/config
## Relocate any other config entries
sed -i -e "/lxc./{w ${path}/config-auto" -e "d}" $path/config
@@ -529,7 +551,7 @@
echo "" >> $path/config
echo "# Container specific configuration" >> $path/config
[ -e "$path/config-auto" ] && cat $path/config-auto >> $path/config && rm $path/config-auto
- grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config
+ grep -q "^lxc.rootfs.path" $path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs" >> $path/config
cat <<EOF >> $path/config
lxc.utsname = $name
lxc.arch = $arch
@@ -674,7 +696,7 @@
[-F | --flush-cache] [-r|--release <release>] [-v|--variant] [ -S | --auth-key <keyfile>]
[--rootfs <rootfs>] [--packages <packages>] [-u|--user <user>] [--password <password>]
[--mirror <url>] [--security-mirror <url>]
-release: the ubuntu release (e.g. precise): defaults to host release on ubuntu, otherwise uses latest LTS
+release: the ubuntu release (e.g. xenial): defaults to host release on ubuntu, otherwise uses latest LTS
variant: debootstrap variant to use (see debootstrap(8))
bindhome: bind <user>'s home into the container
The ubuntu user will not be created, and <user> will have
@@ -694,7 +716,7 @@
fi
eval set -- "$options"
-release=precise # Default to the last Ubuntu LTS release for non-Ubuntu systems
+release=xenial # Default to the last Ubuntu LTS release for non-Ubuntu systems
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
if [ "$DISTRIB_ID" = "Ubuntu" ]; then
@@ -809,8 +831,8 @@
config="$path/config"
# if $rootfs exists here, it was passed in with --rootfs
if [ -z "$rootfs" ]; then
- if grep -q '^lxc.rootfs' $config 2>/dev/null ; then
- rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config)
+ if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then
+ rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config)
else
rootfs=$path/rootfs
fi