English pages are provided only to compare translations to original pages,
better looking pages can be browsed
at the Linux man-pages official site.
Linux Programmer's Manual (2)
pivot_root - change the root filesystem
int pivot_root(const char *new_root, const char *put_old);
There is no glibc wrapper for this system call; see NOTES.
moves the root filesystem of the calling process to the
and makes new_root
the new root filesystem
of the calling process.
The typical use of
is during system startup, when the
system mounts a temporary root filesystem (e.g., an initrd), then
mounts the real root filesystem, and eventually turns the latter into
the current root of all relevant processes or threads.
may or may not change the current root and the current
working directory of any processes or threads which use the old
The caller of
must ensure that processes with root or current working directory
at the old root operate correctly in either case.
An easy way to ensure this is to change their
root and current working directory to new_root before invoking
The paragraph above is intentionally vague because the implementation
may change in the future.
At the time of writing,
changes root and current working directory of each process or
thread to new_root if they point to the old root directory.
is necessary in order to prevent kernel threads from keeping the old
root directory busy with their root and current working directory,
even if they never access
the filesystem in any way.
In the future, there may be a mechanism for
kernel threads to explicitly relinquish any access to the filesystem,
such that this fairly intrusive mechanism can be removed from
Note that this also applies to the calling process:
or may not affect its current working directory.
It is therefore recommended to call
chdir("/") immediately after
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 filesystem 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 filesystem may be mounted on put_old.
for additional usage examples.
If the current root is not a mount point (e.g., after
see also below), not the old root directory, but the
mount point of that filesystem is mounted on put_old.
new_root does not have to be a mount point.
In this case,
/proc/mounts will show the mount point of the filesystem containing
new_root as root (/).
On success, zero is returned.
On error, -1 is returned, and
is set appropriately.
may return (in errno
) any of the errors returned by
Additionally, it may return:
new_root or put_old are on the current root filesystem,
or a filesystem is already mounted on put_old.
put_old is not underneath new_root.
new_root or put_old is not a directory.
The calling process does not have the
was introduced in Linux 2.3.41.
is Linux-specific and hence is not portable.
Glibc does not provide a wrapper for this system call; call it using
should not have to change root and current working directory of all other
processes in the system.
Some of the more obscure uses of
may quickly lead to
This page is part of release 3.66 of the Linux
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
- RETURN VALUE
- CONFORMING TO
- SEE ALSO
This document was created by
using the manual pages.
Time: 21:42:58 GMT, July 12, 2014