From cf49bda43a3a7c487f1d8054839436f20b13b2d6 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 18 Aug 2020 10:46:28 +0200 Subject: [PATCH] Load loop module before starting the container (#824) This makes sure that the kernel module loop is loaded, the loop devices under /dev have been created before the container starts. Docker uses the current /dev as template for the container /dev. If the loop entries are missing, loop devices can't be used inside the container. Use losetup which does not make assumption weather loop support is built-in. This fixes issues seen on my machine when entering the build environment the first time after build: mount: /mnt/data: failed to setup loop device for /export/data.ext4. make[2]: *** [package/pkg-generic.mk:364: /build/buildroot/output_rpi4/build/hassio-1.0.0/.stamp_target_installed] Error 32 --- scripts/enter.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/enter.sh b/scripts/enter.sh index cc6c619c2..71791c8a8 100755 --- a/scripts/enter.sh +++ b/scripts/enter.sh @@ -6,6 +6,10 @@ CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}" sudo mkdir -p "${CACHE_DIR}" sudo chown -R "${BUILDER_UID}:${BUILDER_GID}" "${CACHE_DIR}" sudo docker build -t hassos:local . + +# Make sure loop devices are present before starting the container +sudo losetup -f > /dev/null + sudo docker run -it --rm --privileged \ -v "$(pwd):/build" -v "${CACHE_DIR}:/cache" \ -e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \