How to fix: pivot_root Device or resource busy error

68 Views Asked by At

I'm trying out pivot_root in the terminal. After creating a new mount namespace, I mounted a tmpfs filesystem onto /. Then I created a new directory and mounted a tmpfs filesystem onto the new directory. But when I tried to invoke pivot_root on the two, I received the error - "pivot_root: failed to change root from /' to /tmp/new-root': Device or resource busy". Any idea on why this is happening? Here are the commands:

brianshih@brianshih ~$ sudo unshare -m
[sudo] password for brianshih: 
root@brianshih:/home/brianshih# mkdir /tmp/new-root
root@brianshih:/home/brianshih# mount -n -t tmpfs none /
root@brianshih:/home/brianshih# mount -n -t tmpfs none /tmp/new-root
root@brianshih:/home/brianshih# pivot_root / /tmp/new-root
pivot_root: failed to change root from `/' to `/tmp/new-root': Device or resource busy
0

There are 0 best solutions below