Skip to content

Docker: losetup failed to set up loop device: No such file or directory #257

@samtygier

Description

@samtygier

When building with docker I am getting the error:

losetup: /pi-gen/work/2019-02-13-Raspbian/export-image/2019-02-13-Raspbian-lite.img: failed to set up loop device: No such file or directory

even though that file does exist.

To reproduce, make docker build stop at final rsync in export-image/prerun.sh . Loop devices are at kernel level outside the docker container, so they persist after the failure. They can be seen with the command losetup --list

The unmount_image function in scripts/common uses:
LOOP_DEVICES=$(losetup -j "${1}" | cut -f1 -d':')
but does not see the old loop devices, because the path is missing the "/pi-gen/work", so it is unable to remove them. I imagine the path difference is to do with the how the container views the filesystem. This can be solved by listing all the loop devices, and matching by filename (patch to follow).

There are a few older closed bugs mentioning the issue, #104 #193

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions