1

I want to change the mount point of /tmp. However there are several processes keeping it busy. Is there a way to umount without killing those processes? e.g. suspending them etc.

  • imho, you can't do this without disrupting processes which might having temporary data in the previous location that might be vital to their survival. – sjsam Sep 1 '16 at 16:32
  • No, unless you are really really good with gdb and even then yeah just kill the processes and remount, or reboot the box with the new mount. – thrig Sep 1 '16 at 16:41
  • Which kernel (Linux, *BSD, etc.)? – derobert Sep 1 '16 at 17:09
  • it's CentOS 7 @derobert – roymaztang Sep 1 '16 at 17:18
5

You can do a lazy un-mount (umount -l), which will detach the mount from /tmp. You can then mount whatever other filesystem you'd like on /tmp. Note that the old /tmp will still be mounted, just not visible (except to those few processes still using it). It'll eventually be unmounted when those processes stop using it. So, e.g., it'd be a bad idea to mkfs the underlying storage.

Another alternative (if it works, depends on which of your mounts have "shared" propagation) is mount --move to move the mount to a different directory (e.g., mkdir /oldtmp; mount --move /tmp /oldtmp;); then you can again mount a new filesystem on /tmp.

  • Unfortunately, the mount seems to have shared propagation. I received the error bad option. Note that moving a mount residing under a shared mount is unsupported when I tried mount --move. What's the cause of this error? Is it because it's shared by NFS? – roymaztang Sep 1 '16 at 19:24
  • 1
    @roymaztang shared refers to between mount namespaces, which is a container feature. Nothing to do with NFS. You should still be able to lazy unmount it. – derobert Sep 1 '16 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.