Mount xfs inside container fails


I’m trying to create and mount xfs image inside the container.
When I do:

truncate -s 1G img
mkfs.xfs img
mkdir img-mnt
mount -o loop img img-mnt

I get

mount: img-mnt: mount failed: Unknown error -1

Is it possible to do inside the container?
If yes what am I missing?

LXD version 3.15


No, both loop devices and xfs mounting isn’t allowed inside unprivileged containers.

It is possible to make this work inside a privileged container, but you’ll need to manually setup unix-char devices for /dev/loop-control and /dev/loop0 through /dev/loop7 (possibly more if you need more) and then put something like mount fstype=xfs, in the raw.apparmor config key.

Note that this would be rather unsafe, so fine if you’re the one running the container and you trust the xfs filesystem you’re mounting, not so fine if you’re having an untrusted user do this.

Thanks for answer,
I’ll give it a shot.

I started looking for ways how I can manually setup unix-char devices and stuck. I can’t create loop device. In my container, I don’t have the loop module for the kernel. Is it normal? @stgraber Can you point me where can I find information about manual managing unix-char devices (/dev/loop-contro and /dev/loop0…)?

lxc config deivce add CONTAINER loop0 unix-char path=/dev/loop0

repeat for loop1 through loop7 or so and loop-control on top of that

I also just found this helpful