lxc-create fails on 3.13.0 with "mknod: dev/zero: File exists"
There is something wrong with the template, or newer versions of lxc create some device nodes by default. The following changes to /usr/share/lxc/templates/lxc-alpine
fix this:
--- lxc-alpine
+++ lxc-fazal
@@ -277,10 +277,10 @@
mkdir -p -m 755 dev/pts
mkdir -p -m 1777 dev/shm
- mknod -m 666 dev/zero c 1 5
+ #mknod -m 666 dev/zero c 1 5
mknod -m 666 dev/full c 1 7
- mknod -m 666 dev/random c 1 8
- mknod -m 666 dev/urandom c 1 9
+ #mknod -m 666 dev/random c 1 8
+ #mknod -m 666 dev/urandom c 1 9
local i; for i in $(seq 0 4); do
mknod -m 620 dev/tty$i c 4 $i
@@ -289,7 +289,7 @@
mknod -m 666 dev/tty c 5 0
chown 0:5 dev/tty # root:tty
- mknod -m 620 dev/console c 5 1
+ #mknod -m 620 dev/console c 5 1
mknod -m 666 dev/ptmx c 5 2
chown 0:5 dev/ptmx # root:tty
}
here is the error without the changes:
zulfiqar:~# lxc-create -t alpine -n foo
Obtaining an exclusive lock... done
==> Fetching and/or verifying APK keys
alpine-devel@lists.alpinelinux.org-4a6a0840.rsa.pub: OK
alpine-devel@lists.alpinelinux.org-4d07755e.rsa.pub: OK
alpine-devel@lists.alpinelinux.org-5243ef4b.rsa.pub: OK
alpine-devel@lists.alpinelinux.org-524d27bb.rsa.pub: OK
alpine-devel@lists.alpinelinux.org-5261cecb.rsa.pub: OK
alpine-devel@lists.alpinelinux.org-58199dcc.rsa.pub: OK
alpine-devel@lists.alpinelinux.org-58cbb476.rsa.pub: OK
alpine-devel@lists.alpinelinux.org-58e4f17d.rsa.pub: OK
Obtaining an exclusive lock... done
==> Installing Alpine Linux in /var/lib/lxc/foo/rootfs
fetch http://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/20) Installing musl (1.2.2-r0)
(2/20) Installing busybox (1.32.1-r0)
Executing busybox-1.32.1-r0.post-install
(3/20) Installing alpine-baselayout (3.2.0-r8)
Executing alpine-baselayout-3.2.0-r8.pre-install
Executing alpine-baselayout-3.2.0-r8.post-install
(4/20) Installing ifupdown-ng (0.10.2-r2)
(5/20) Installing openrc (0.42.1-r19)
Executing openrc-0.42.1-r19.post-install
(6/20) Installing alpine-conf (3.11.0-r2)
(7/20) Installing libcrypto1.1 (1.1.1i-r0)
(8/20) Installing libssl1.1 (1.1.1i-r0)
(9/20) Installing ca-certificates-bundle (20191127-r5)
(10/20) Installing libtls-standalone (2.9.1-r1)
(11/20) Installing ssl_client (1.32.1-r0)
(12/20) Installing zlib (1.2.11-r3)
(13/20) Installing apk-tools (2.12.0-r4)
(14/20) Installing busybox-suid (1.32.1-r0)
(15/20) Installing busybox-initscripts (3.2-r2)
Executing busybox-initscripts-3.2-r2.post-install
(16/20) Installing scanelf (1.2.8-r0)
(17/20) Installing musl-utils (1.2.2-r0)
(18/20) Installing libc-utils (0.7.2-r3)
(19/20) Installing alpine-keys (2.2-r0)
(20/20) Installing alpine-base (3.13.0-r0)
Executing busybox-1.32.1-r0.trigger
OK: 9 MiB in 20 packages
mknod: dev/zero: File exists
lxc-create: foo: lxccontainer.c: create_run_template: 1616 Failed to create container from template
lxc-create: foo: tools/lxc_create.c: main: 319 Failed to create container foo