mv: cannot move "home" to "home-old": Device or resource busy

mv: cannot move "/home" to "/home-old": Device or resource busy

The only "use"[*] I can think of, which holds the name of a file from changing, is a mount point.

What else can I check?

I am not certain, but perhaps this could happen if the mount still exists in another mount namespace. Because it's not getting unmounts propagated from the root namespace, for some reason? Or looking at the result on my system, maybe systemd services with ProtectHome?

$ grep -h home /proc/*/task/*/mountinfo | sort -u
121 89 0:22 /systemd/inaccessible/dir /home ro,nosuid,nodev shared:142 master:24 - tmpfs tmpfs rw,seclabel,mode=755
275 243 253:2 / /home ro,relatime shared:218 master:33 - ext4 /dev/mapper/alan_dell_2016-home rw,seclabel,data=ordered
321 288 253:2 / /home rw,relatime shared:262 master:33 - ext4 /dev/mapper/alan_dell_2016-home rw,seclabel,data=ordered
84 64 253:2 / /home rw,relatime shared:33 - ext4 /dev/mapper/alan_dell_2016-home rw,seclabel,data=ordered
85 46 253:2 / /home rw,relatime master:33 - ext4 /dev/mapper/alan_dell_2016-home rw,seclabel,data=ordered

Note this issue - unable to rename /home despite it not showing as a mount point (in the current namespace) - should be fixed in Linux kernel version 3.18+.

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?h=linux-3.18.y&id=8ed936b5671bfb33d89bc60bdcc7cf0470ba52fe


how to find out namespace of a particular process?

lsns might be useful if you can install it. More possible commands:

List mount namespaces:

# readlink /proc/*/task/*/ns/mnt | sort -u

Identify root mount namespace:

# readlink /proc/1/ns/mnt

Find processes with a given mount namespace

# readlink /proc/*/task/*/ns/mnt | grep 4026531840

Inspect the namespace of a given process:

# cat /proc/1/task/1/mountinfo

[*] EBUSY The rename fails because oldpath or newpath is a directory that is in use by some process (perhaps as current working directory, or as root directory, or because it was open for reading) or is in use by the system (for example as mount point), while the system considers this an error. (Note that there is no require‐ ment to return EBUSY in such cases—there is nothing wrong with doing the rename anyway—but it is allowed to return EBUSY if the system cannot otherwise handle such situations.)


It was NetworkManager.

Running systemctl stop mysqld httpd postfix ipmievd tuned atd rsyslog smartd crond irqbalance gssproxy polkit chronyd didn't help, but made the process table very small.

After systemctl stop NetworkManager, I was able to rename /home.