From: Michael Kerrisk Date: Sat, 27 Jul 2019 17:07:39 +0000 (+0200) Subject: pivot_root.2: Relocate text on use cases and add text on purpose of pivot_root(2) X-Git-Tag: man-pages-5.03~116 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=422e36b7f2f68073d9b46bace8e98d4f40f399aa;p=thirdparty%2Fman-pages.git pivot_root.2: Relocate text on use cases and add text on purpose of pivot_root(2) Signed-off-by: Michael Kerrisk --- diff --git a/man2/pivot_root.2 b/man2/pivot_root.2 index 0428a5eb3e..db2c782828 100644 --- a/man2/pivot_root.2 +++ b/man2/pivot_root.2 @@ -25,15 +25,6 @@ The calling process must have the .B CAP_SYS_ADMIN capability in the user namespace that owns the caller's mount namespace. .PP -A typical use of -.BR pivot_root () -is during system startup, when the -system mounts a temporary root filesystem (e.g., an \fBinitrd\fP), then -mounts the real root filesystem, and eventually turns the latter into -the current root of all relevant processes or threads. -A modern use is to set up a root filesystem during -the creation of a container. -.PP .BR pivot_root () may or may not change the current root and the current working directory of any processes or threads that @@ -166,6 +157,24 @@ is Linux-specific and hence is not portable. Glibc does not provide a wrapper for this system call; call it using .BR syscall (2). .PP +.BR pivot_root () +allows the caller to switch to a new root filesystem while at the same time +placing the old root mount at a location under +.I new_root +from where it can subsequently be unmounted. +(The fact that it moves all processes that have a root directory +or current working directory on the old root filesystem to the +new root filesystem frees the old root filesystem of users, +allowing it to be unmounted more easily.) +A typical use of +.BR pivot_root () +is during system startup, when the +system mounts a temporary root filesystem (e.g., an \fBinitrd\fP), then +mounts the real root filesystem, and eventually turns the latter into +the current root of all relevant processes or threads. +A modern use is to set up a root filesystem during +the creation of a container. +.PP The rootfs (initial ramfs) cannot be .BR pivot_root ()ed. The recommended method of changing the root filesystem in this case is