void-mklive icon indicating copy to clipboard operation
void-mklive copied to clipboard

tmpfs error when building void iso in docker container

Open wbehrens-on-gh opened this issue 3 years ago • 5 comments

I'm trying to build a custom void .iso in a docker container to test since the system I'm on currently isn't running void. I've included the commands & dockerfile I've been using to try and build as well as the error error

[7/9] Generating GRUB support for EFI systems...
umount: /root/tmp.cyQs8TRvyC: not mounted.
[8/9] Cleaning up rootfs...
[9/9] Generating squashfs image (xz) from rootfs...
mount: /mklive/tmp.fncIhavHpt/tmp-rootfs: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
umount: /mklive/tmp.fncIhavHpt/tmp-rootfs: not mounted.
/mklive/tmp.fncIhavHpt/void-host/usr/bin/mksquashfs: error while loading shared libraries: liblzo2.so.2: cannot open shared object file: No such file or directory
ERROR: Failed to generate squashfs image
make: *** [Makefile:22: build] Error 1

build_iso.sh

#!/bin/sh

set -eu

. /config/packages

cd /mklive || exit 1

echo "./mklive.sh \"$REPO\" -a \"$ARCH\" -p \"$PKGS\" -S \"$SERVICES\" -T \"$NAME\" -o \"/output/$ISO\""

./mklive.sh "$REPO" \
    -a "$ARCH" \
    -p "$PKGS" \
    -S "$SERVICES" \
    -T "$NAME" \
    -o "/output/$ISO" 

Dockerfile

FROM voidlinux/voidlinux

ARG repo=https://repo-default.voidlinux.org/

ENV VERSION=0
ENV ARCH=x86_64
ENV NAME=willows
ENV REPO=${repo}
ENV ISO=${NAME}-${VERSION}-${ARCH}.iso

# mklive must be run as root
USER root

# Install required packages
RUN xbps-install -Syu \
        xbps \
        git \
        kmod \
        make \
        bash \
        liblz4 \
        qemu-user-static

# Clone and build mklive
RUN git clone https://github.com/void-linux/void-mklive /mklive \
    && make -C /mklive

# Create volumes to transfer information
RUN mkdir -p /output /config
VOLUME [ "/output" ]
VOLUME [ "/config" ]

# Run the build script
COPY scripts/build_iso.sh /usr/bin/build_iso
RUN chmod +x /usr/bin/build_iso
CMD [ "build_iso" ]

docker run: docker run --privileged --cap-add=SYS_ADMIN -v ${OUTDIR}:/output -v ${CONFIG}:/config -e NAME=${NAME} -e ARCH=${ARCH} -e VERSION=${VERSION} ${NAME}:${TAG}

wbehrens-on-gh avatar Oct 16 '22 05:10 wbehrens-on-gh

one of the errors is caused by a missing dependency: squashfs-tools

however, I'm not sure this will work at all, based on the other error messages. I added squashfs-tools and tried your dockerfile/script myself, and the image generated is 5 times smaller than it should be and does not contain a proper efi partition.

My guess as to what's happening is it's not able to mount and unmount things from inside the container:

[7/9] Generating GRUB support for EFI systems...
umount: /root/tmp.nZsHeKVuRp: not mounted.
[8/9] Cleaning up rootfs...
[9/9] Generating squashfs image (xz) from rootfs...
mount: /mklive/tmp.oNBnYLJ9hV/tmp-rootfs: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.
umount: /mklive/tmp.oNBnYLJ9hV/tmp-rootfs: not mounted.

classabbyamp avatar Oct 16 '22 06:10 classabbyamp

also, the images from dockerhub are old and no longer supported, use ghcr.io/void-linux/void-linux:latest-full-x86_64

classabbyamp avatar Oct 16 '22 07:10 classabbyamp

one of the errors is caused by a missing dependency: squashfs-tools

however, I'm not sure this will work at all, based on the other error messages. I added squashfs-tools and tried your dockerfile/script myself, and the image generated is 5 times smaller than it should be and does not contain a proper efi partition.

My guess as to what's happening is it's not able to mount and unmount things from inside the container:

[7/9] Generating GRUB support for EFI systems...
umount: /root/tmp.nZsHeKVuRp: not mounted.
[8/9] Cleaning up rootfs...
[9/9] Generating squashfs image (xz) from rootfs...
mount: /mklive/tmp.oNBnYLJ9hV/tmp-rootfs: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.
umount: /mklive/tmp.oNBnYLJ9hV/tmp-rootfs: not mounted.

Do you have any more insight on this? like what specifically is being mounted since searching for mounting issues in docker just returns results about the VOLUME function.

wbehrens-on-gh avatar Oct 17 '22 00:10 wbehrens-on-gh

no clue, sorry

classabbyamp avatar Oct 17 '22 01:10 classabbyamp

so, I was able to get this to work in Github CI in a void docker container, using the following:

...
    container:
      image: 'ghcr.io/void-linux/void-linux:20230204RC01-full-x86_64'
      options: --privileged
      volumes:
        - /dev:/dev
      env:
        PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
        REPO: "${{ inputs.mirror }}"

    steps:
      - name: Prepare container
        shell: sh
        run: |
          # Switch to repo-ci mirror
          mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
          sed -i 's|https://repo-default.voidlinux.org/current|'"$REPO"'|g' /etc/xbps.d/*-repository-*.conf
          # Sync and upgrade once, assume error comes from xbps update
          xbps-install -Syu || xbps-install -yu xbps
          # Upgrade again (in case there was a xbps update)
          xbps-install -yu
          # Install depedencies
          xbps-install -yu bash make git kmod xz lzo qemu-user-static outils dosfstools e2fsprogs
...

(it then goes on to clone the repo and build things, see #331)

the important parts are:

  • it uses a current void docker image
  • it passes --privileged to docker run
  • it mounts /dev in the container, so loopback devices can work (they get mounted properly and the kernel tree can see them, but the filesystem nodes are not added without this)

DISCLAIMER: I have no clue what this will do on a machine that isn't some throwaway CI VM, so be careful.

classabbyamp avatar Apr 09 '23 05:04 classabbyamp