You are not logged in.

#1 2015-06-24 17:25:42

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Loopback device in a container?

I'm attempting to use a loopback device inside a container, to mount some image file:

> sudo losetup /dev/loop0 test.img
losetup: /dev/loop0: failed to set up loop device: No such file or directory

/dev/loop0 indeed doesn't exist inside the container, and

> sudo mknod /dev/loop0 b 7 0
mknod: ‘/dev/loop0’: Operation not permitted

How can I make this work? Does the container need some cgroup permission that it might not have?

Addition: I found out that I need more privileges, so I added

 --capability=all

to the systemd-nspawn invocation. And executing

echo b 7:0 rwm > /sys/fs/cgroup/devices/machine.slice/machine-NAME.scope/devices.allow

on the host allows me to mknod. But then I get a

losetup: /dev/loop0: failed to set up loop device: Inappropriate ioctl for device

and I would suspect that it has to do with /dev being a tmpfs rather than a tmpfs in the container; but I'm guessing. So far, progress, but no cigar, in other words.

Last edited by jernst (2015-06-24 21:19:07)

Offline

#2 2015-06-25 09:31:45

p0x8
Member
Registered: 2012-09-20
Posts: 70

Re: Loopback device in a container?

This is backtracking to the basics, but have you made sure the loop kernel module is loaded?

Offline

#3 2015-06-25 16:55:18

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Re: Loopback device in a container?

p0x8: Yes. It works fine on the host, and the modules loaded from the host also show up in the container.

Offline

Board footer

Powered by FluxBB