How to use/test pivot_root?
Solution 1
Are you really sure that arch-root
is on a separate filesystem that can be mounted and umounted?
pivot_root
, as well as the more current switch_root
, works by juggling information about mounted filesystems in the kernel.
The new root file system must be "the root" of a file system, you cannot pass "." as the new root unless "." is the root directory of a mounted filesystem.
I believe the easiest way if you want to try pivot_root
from your current setup (assuming arch-root is a subdirectory and not a root directory) is to create a tmpfs
filesystem to switch to, and copy the required stuff there.
Something along these lines might get you started: (adjust 500M to fit du -sh arch-root
)
mkdir /ramroot mount -n -t tmpfs -o size=500M none /ramroot cd arch-root # (containing the root filesystem contents) find . -depth -xdev -print | cpio -pd --quiet /ramroot cd /ramroot mkdir oldroot pivot_root . oldroot exec chroot . bin/sh
Solution 2
From the man page, I believe this is your issue:
The following restrictions apply to new_root and put_old:
- They must be directories.
- new_root and put_old must not be on the same file system as the current
root.
- put_old must be underneath new_root, that is, adding a nonzero number of
/.. to the string pointed to by put_old must yield the same directory as
new_root.
- No other file system may be mounted on put_old.
According to the above neither put_old
or new_root
filesystems should reside on the same filesystem as current_root
.
References
Related videos on Youtube
Nixiean
Updated on September 18, 2022Comments
-
Nixiean over 1 year
I have a variable in which I populate the image location dynamically.
I need to change the background image with that variable. I am not able to find a way to do that.
var myImg = '/images/example1.jpg'; document.body.style.background = "url(myImg) no-repeat";
This doesn't seem to work.
Is there a syntax issue or should this be done in a different way?
-
Admin over 9 yearsFrom the sound of this post it sounds like a bug to me: github.com/lxc/lxc/issues/61. This thread too sounds related: lists.linuxcontainers.org/pipermail/lxc-users/2014-January/…
-
Admin over 9 yearsYea I am trying to test the function of Docker and lxc feature which use pivot_root
-
-
Nixiean about 11 yearsThanks a lot for the answer. I am just learning. Really appreciate the quick help..
-
vvilp over 9 yearsThank you for your reply. I update the question. I also try to test in Docker. But Operation not permitted
-
vvilp over 9 yearsThank you very much, For now I am testing it in a docker container. it works. I will try your method later
-
koalo almost 6 yearsYou might need to do an
unshare -m
before the pivot_root. bugzilla.redhat.com/show_bug.cgi?id=1361043 -
iBug about 4 yearsYour summary is wrong.
new_root
andput_old
can be on the same FS, it's just that neither should reside on the same FS as the current root. -
slm about 4 years@iBug - ty fixed.