Sample Header Ad - 728x90

How to unmount a drive while a container is running?

0 votes
0 answers
76 views
I have a Linux (6.6.x) machine with hotswap chassis that allows drives to be inserted and removed without downtime. The system has the following drives: - /dev/sda (operating system) - /dev/sdb (removable storage) Within the directory where /dev/sda is mounted, I launch any container application, with docker, podman, etc. It only touches files that are stored on /dev/sda. I then umount /dev/sdb which succeeds if nothing is using it. But when I grep sdb /proc/*/mounts all the processes launched within the container are continuing to hold /dev/sdb mount open, even though it has been unmounted in the root level. I've also verified this under /sys/fs seeing that the filesystem is still active. 1. I've tried setting different propagation shared, slave, private in fstab, without success. The unmount doesn't seem to propagate from the top namespace into the container namespace. 2. I tried running unmount within the container by nsentering the container. But it throws a EINVAL target is locked; see mount_namespaces(7) error. ----- Per mount_namespaces(7), when a container application is launched **"the mount list of the child's namespace is a copy of the mount list in the parent process's mount namespace"** Also per mount_namespaces(7) **"Mounts that come as a single unit from a more privileged mount namespace are locked together and may not be separated"** ----- a. Do these constraints mean that every container on the system must be shutdown before *any* drive on a computer can be unmounted? b. Or is there a way to exclude irrelevant drives from being copied into container mount namespaces? c. Or is there a solution to allow unmount to propagate from the top-level context to all containers?
Asked by anthonyryan1 (53 rep)
Mar 23, 2025, 11:33 PM
Last activity: Apr 9, 2025, 12:17 AM