]>
Commit | Line | Data |
---|---|---|
8d3abdc0 | 1 | .TH PIVOT_ROOT 8 "August 2011" "util-linux" "System Administration" |
22853e4a | 2 | .SH NAME |
232dc924 | 3 | pivot_root \- change the root filesystem |
22853e4a KZ |
4 | .SH SYNOPSIS |
5 | .B pivot_root | |
48962512 | 6 | .I new_root put_old |
22853e4a KZ |
7 | .SH DESCRIPTION |
8 | \fBpivot_root\fP moves the root file system of the current process to the | |
9 | directory \fIput_old\fP and makes \fInew_root\fP the new root file system. | |
48962512 | 10 | Since \fBpivot_root\fP(8) simply calls \fBpivot_root\fP(2), we refer to |
22853e4a KZ |
11 | the man page of the latter for further details. |
12 | ||
13 | Note that, depending on the implementation of \fBpivot_root\fP, root and | |
14 | cwd of the caller may or may not change. The following is a sequence for | |
15 | invoking \fBpivot_root\fP that works in either case, assuming that | |
16 | \fBpivot_root\fP and \fBchroot\fP are in the current \fBPATH\fP: | |
17 | .sp | |
18 | cd \fInew_root\fP | |
19 | .br | |
20 | pivot_root . \fIput_old\fP | |
21 | .br | |
22 | exec chroot . \fIcommand\fP | |
23 | .sp | |
24 | Note that \fBchroot\fP must be available under the old root and under the new | |
25 | root, because \fBpivot_root\fP may or may not have implicitly changed the | |
26 | root directory of the shell. | |
27 | ||
28 | Note that \fBexec chroot\fP changes the running executable, which is | |
29 | necessary if the old root directory should be unmounted afterwards. | |
30 | Also note that standard input, output, and error may still point to a | |
31 | device on the old root file system, keeping it busy. They can easily be | |
32 | changed when invoking \fBchroot\fP (see below; note the absence of | |
33 | leading slashes to make it work whether \fBpivot_root\fP has changed the | |
34 | shell's root or not). | |
8d3abdc0 SK |
35 | .SH OPTIONS |
36 | .TP | |
37 | \fB\-V\fR, \fB\-\-version\fR | |
b4362b6f | 38 | Display version information and exit. |
8d3abdc0 SK |
39 | .TP |
40 | \fB\-h\fR, \fB\-\-help\fR | |
b4362b6f | 41 | Display help text and exit. |
22853e4a KZ |
42 | .SH EXAMPLES |
43 | Change the root file system to /dev/hda1 from an interactive shell: | |
44 | .sp | |
45 | .nf | |
46 | mount /dev/hda1 /new-root | |
47 | cd /new-root | |
48 | pivot_root . old-root | |
49 | exec chroot . sh <dev/console >dev/console 2>&1 | |
50 | umount /old-root | |
51 | .fi | |
52 | .sp | |
53 | Mount the new root file system over NFS from 10.0.0.1:/my_root and run | |
54 | \fBinit\fP: | |
55 | .sp | |
56 | .nf | |
57 | ifconfig lo 127.0.0.1 up # for portmap | |
58 | # configure Ethernet or such | |
59 | portmap # for lockd (implicitly started by mount) | |
60 | mount -o ro 10.0.0.1:/my_root /mnt | |
61 | killall portmap # portmap keeps old root busy | |
62 | cd /mnt | |
63 | pivot_root . old_root | |
64 | exec chroot . sh -c 'umount /old_root; exec /sbin/init' \\ | |
65 | <dev/console >dev/console 2>&1 | |
66 | .fi | |
67 | .SH "SEE ALSO" | |
48962512 | 68 | .BR chroot (1), |
48962512 | 69 | .BR pivot_root (2), |
f053ff1e | 70 | .BR mount (8), |
922eafb2 | 71 | .BR switch_root (8), |
48962512 | 72 | .BR umount (8) |
86d62711 | 73 | .SH AVAILABILITY |
601d12fb KZ |
74 | The pivot_root command is part of the util-linux package and is available from |
75 | ftp://ftp.kernel.org/pub/linux/utils/util-linux/. |