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

Failure to mount loop devices #1168

Open
1 of 5 tasks
Crown0815 opened this issue Oct 22, 2024 · 0 comments
Open
1 of 5 tasks

Failure to mount loop devices #1168

Crown0815 opened this issue Oct 22, 2024 · 0 comments

Comments

@Crown0815
Copy link

Description

Given the following Dockerfile

FROM debian:bookworm-slim
WORKDIR /code/
ENTRYPOINT ["bash"]

when running the following script (run.sh)

docker build --quiet --tag 'test_image' .
docker run -it -v "$PWD/:/code" --cap-add SYS_ADMIN --device=/dev/loop0 'test_image' /code/test.sh

with test.sh containing

#!/bin/bash

# Create a 10MB image file and initialize an ext4 filesystem on it
dd if=/dev/zero bs=1M count=10 > test.img
mkfs.ext4 -O uninit_bg test.img

# Mount the image file as a loop device, and then mount it at /mnt
LOOP_DEVICE="$(losetup --find --show test.img)"
mount "$LOOP_DEVICE" /mnt

I receive an error for the mount command saying

mount: /mnt: cannot mount /dev/loop0 read-only.
       dmesg(1) may have more information after failed mount system call.

So I checked dmesg and found these errors:

...
[   31.517064] loop0: detected capacity change from 0 to 4096
[   31.519716] operation not supported error, dev loop0, sector 0 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0
[   31.521012] operation not supported error, dev loop0, sector 0 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0
[   31.522290] operation not supported error, dev loop0, sector 3968 op 0x9:(WRITE_ZEROES) flags 0x8000800 phys_seg 0 prio class 0
[   31.523994] operation not supported error, dev loop0, sector 272 op 0x9:(WRITE_ZEROES) flags 0x8000800 phys_seg 0 prio class 0
[   31.525954] operation not supported error, dev loop0, sector 152 op 0x9:(WRITE_ZEROES) flags 0x8000800 phys_seg 0 prio class 0
[   31.615215] loop0: detected capacity change from 0 to 4104
[   31.617421] operation not supported error, dev loop0, sector 0 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0
[   31.618592] operation not supported error, dev loop0, sector 0 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0
[   31.619754] operation not supported error, dev loop0, sector 3968 op 0x9:(WRITE_ZEROES) flags 0x8000800 phys_seg 0 prio class 0
[   31.623177] operation not supported error, dev loop0, sector 272 op 0x9:(WRITE_ZEROES) flags 0x8000800 phys_seg 0 prio class 0
[   31.624677] operation not supported error, dev loop0, sector 152 op 0x9:(WRITE_ZEROES) flags 0x8000800 phys_seg 0 prio class 0
[   31.716454] loop0: detected capacity change from 0 to 4096
...

It seems there is some issue with mounting loop devices in colima.
The same code works fine when using Docker Desktop.

Version

colima version 0.7.5
git commit: 1588c06
limactl version 0.23.2
qemu-img version 9.1.0
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

Operating System

  • macOS Intel <= 13 (Ventura)
  • macOS Intel >= 14 (Sonoma)
  • Apple Silicon <= 13 (Ventura)
  • Apple Silicon >= 14 (Sonoma)
  • Linux

Output of colima status

No response

Reproduction Steps

  1. Start colima (colima start --memory 8, though the 8GB of RAM are not necessary for this test, just the setup I used)
  2. Create the scripts/Dockerfile described above\
  3. Run the run.sh script
  4. Observe the output
  5. Enter the colima vm (colima ssh)
  6. Check dmesg (sudo dmesg) and look for all messages containing loop0

Expected behaviour

The mount should work fine, as it does on Docker Desktop

Additional context

No response

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
@Crown0815 and others