Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmpfs error when building void iso in docker container #289

Open
wbehrens-on-gh opened this issue Oct 16, 2022 · 5 comments
Open

tmpfs error when building void iso in docker container #289

wbehrens-on-gh opened this issue Oct 16, 2022 · 5 comments

Comments

@wbehrens-on-gh
Copy link

wbehrens-on-gh commented Oct 16, 2022

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}

@classabbyamp
Copy link
Member

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
Copy link
Member

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

@wbehrens-on-gh
Copy link
Author

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.

@classabbyamp
Copy link
Member

no clue, sorry

@classabbyamp
Copy link
Member

classabbyamp commented Apr 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants