Sample Header Ad - 728x90

How to use/test pivot_root?

17 votes
3 answers
20957 views
I want to test the [pivot_root](http://man7.org/linux/man-pages/man8/pivot_root.8.html) command which moves the root file system of the current process to the directory put_old and makes new_root the new root file system. *But I always get the following error:* pivot_root: failed to change root from .' toold-root/': Invalid argument I use fedora as base root, I have a Archlinux in my home folder [root@localhost arch-root]# ls bin boot dev etc home lib lib64 mnt old-root opt proc root run sbin srv sys tmp usr var [root@localhost arch-root]# pivot_root . old-root/ pivot_root: failed to change root from .' toold-root/': Invalid argument I also try to call linux function pivot_root("/chroot_test", "/chroot_test/old-root"); Got same error. Any ideas about this ? ### Update #1 I also try to test pivot_root in Docker. I mount this arch-root in to Docker container. But get the following error: Operation not permitted root@00d871ce892b:/# cd test_root/ root@00d871ce892b:/test_root# ls bin boot dev etc home lib lib64 mnt old-root opt proc root run sbin srv sys test_pivot_root test_pivot_root.c tmp usr var root@00d871ce892b:/test_root# pivot_root . tmp/ pivot_root: Operation not permitted
Asked by vvilp (381 rep)
Sep 16, 2014, 12:32 AM
Last activity: Feb 24, 2025, 08:32 PM