Linux – pivot_root device or resource busy

linux

The following commands on Ubuntu 64bit on VMWare:

mount /dev/sda1 /newroot
cd /newroot
mkdir old-root
pivot_root . old-root

produce an error that I do not understand:

pivot_root: device or resource busy

Any ideas what might be the reason for that?

Edit: strace result

`strace pivot_root . old-root 
execve("/usr/sbin/pivot_root", ["pivot_root", ".", "old-root"], [/* 67 vars */]) = 0
brk(0)                                  = 0x77e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2df4135000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=124467, ...}) = 0
mmap(NULL, 124467, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2df4116000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\36b\0075\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2096496, ...}) = 0`

Best Answer

You should unmount the /proc file system first and then execute your original set of commands.

umount /proc
mount /dev/sda1 /newroot
cd /newroot
mkdir old-root
pivot_root . old-root