问题原文
原帖链接 · Johannes Ernst · CC BY-SA 4.0
I'm attempting to use a loop 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, 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?
社区高分解答
原帖链接 · Troels Folke · CC BY-SA 3.0
If you're using systemd-nspawn, start up your container with the --capability=CAP_MKNOD command line switch. This will allow you to create device nodes inside your container. Then create a loop device like this:
# mknod /dev/loop0 b 7 0
Remember that this loop device is shared with the host and is called /dev/loop0 there as well. And that it is now possible to access host devices if you know the major and minor numbers. There could also be other consequences that I haven't thought about. Be warned.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
