Replies: 1 comment
-
|
This has nothing to do with podman really, I am not sure why you are even be allowed to manipulate disks. The kernel will never allow an unprivileged user namespace to mount "real" file systems. https://man7.org/linux/man-pages/man7/user_namespaces.7.html
So I would say whatever you want to do is not possible. I don't know how loop devices work in general but if it /dev/loop-control talks to the host and then it will create the device nodes there as it doesn't seem to be namespace aware. You likely would need to create your own device node in the container namespace which again is not possible as the kernel will block that. Permission wise this just doesn't sounds like it can ever work. Now you could try to mount all devices with something like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Issue Description
My ultimate goal is to create a disk image file in a rootless container.
The usual pattern is to create a file (e.g., using
dd), usesfdiskorpartedto create a partition table andlosetupandkpartxto map the file via loop devices,mkfsto create the filesystem,grub2-installor similar for bootable disks, and then finallymountthe loop devices to interact with the filesystem.Anyhow, I'd like to do this in a podman container (one of our build steps is to create a disk/iso image); specifically a rootless container that has the requisite permissions to be able to use loop devices. So far, in order to accomplish this I've had to add my user to the
diskgroup and add the following options:If my disk image were a single partition, I think I'd be ok, as in order to mount the "disk", all I'd need to do is mount
/dev/loop0, which I've already mapped to the container. However, since the disk has multiple partitions, I need to mount/dev/loop0p1and/dev/loop0p2.The
losetupcommand to create those devnodes works in the container, but the devnodes are only visible in the host environment (i.e.,loop0p1andloop0p2are only listed in/devin the host environment, NOT in the podman container).I can't simply add
--device /dev/loop0p1to the podman run command, because at the time of invocation, those devnodes do not exist. They are only created afterlosetupis run.So finally, the issue is there doesn't seem to be a way to get dynamically created devnodes to show up in the (rootless) container...
Steps to reproduce the issue
Steps to reproduce the issue:
diskgroup:sudo usermod -aG disk <user>--device /dev/loop-control:/dev/loop-control:rwm --security-opt unmask=/sys/dev/block --device /dev/loop0:/dev/loop0:rwmIn the container (assuming the container has the parted and losetup utilities)
dd if=/dev/zero of=disk.img bs=1000 count=0 seek=1000000set up the loop device(s):
/sbin/losetup -Pf --show disk.imgrun
ls /dev/loop*(The issue is you will only see /dev/loop-control and /dev/loop0. On the Host you will additionally see /dev/loop0p1 and /dev/loop0p2)
Note: to "clean up" all the loop devices, run
losetup -DDescribe the results you received
The result is I only see
/dev/loop-controland/dev/loop0in the podman container. On the Host/dev/loop0p1and/dev/loop0p2are created, but not visible in the container.Describe the results you expected
I expect to see
/dev/loop-control,/dev/loop0,/dev/loop0p1, and/dev/loop0p2in the container.podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
Oracle Linux 9 is the host OS (running in an OCI VM environment) if that matters.
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions