OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / util-linux / original / man8 / pivot_root.8
1 .TH PIVOT_ROOT 8 "Feb 23, 2000" "Linux" "Maintenance Commands"
2 .SH NAME
3 pivot_root \- change the root file system
4 .SH SYNOPSIS
5 .B pivot_root
6 .RB \fInew_root\fP
7 .RB \fIput_old\fP
8 .SH DESCRIPTION
9 \fBpivot_root\fP moves the root file system of the current process to the
10 directory \fIput_old\fP and makes \fInew_root\fP the new root file system.
11 Since \fBpivot_root(8)\fP simply calls \fBpivot_root(2)\fP, we refer to
12 the man page of the latter for further details.
13
14 Note that, depending on the implementation of \fBpivot_root\fP, root and
15 cwd of the caller may or may not change. The following is a sequence for
16 invoking \fBpivot_root\fP that works in either case, assuming that
17 \fBpivot_root\fP and \fBchroot\fP are in the current \fBPATH\fP:
18 .sp
19 cd \fInew_root\fP
20 .br
21 pivot_root . \fIput_old\fP
22 .br
23 exec chroot . \fIcommand\fP
24 .sp
25 Note that \fBchroot\fP must be available under the old root and under the new
26 root, because \fBpivot_root\fP may or may not have implicitly changed the
27 root directory of the shell.
28
29 Note that \fBexec chroot\fP changes the running executable, which is
30 necessary if the old root directory should be unmounted afterwards.
31 Also note that standard input, output, and error may still point to a
32 device on the old root file system, keeping it busy. They can easily be
33 changed when invoking \fBchroot\fP (see below; note the absence of
34 leading slashes to make it work whether \fBpivot_root\fP has changed the
35 shell's root or not).
36 .SH EXAMPLES
37 Change the root file system to /dev/hda1 from an interactive shell:
38 .sp
39 .nf
40 mount /dev/hda1 /new-root
41 cd /new-root
42 pivot_root . old-root
43 exec chroot . sh <dev/console >dev/console 2>&1
44 umount /old-root
45 .fi
46 .sp
47 Mount the new root file system over NFS from 10.0.0.1:/my_root and run
48 \fBinit\fP:
49 .sp
50 .nf
51 ifconfig lo 127.0.0.1 up   # for portmap
52 # configure Ethernet or such
53 portmap   # for lockd (implicitly started by mount)
54 mount -o ro 10.0.0.1:/my_root /mnt
55 killall portmap   # portmap keeps old root busy
56 cd /mnt
57 pivot_root . old_root
58 exec chroot . sh -c 'umount /old_root; exec /sbin/init' \\
59   <dev/console >dev/console 2>&1
60 .fi
61 .SH "SEE ALSO"
62 .BR chroot(1),
63 .BR mount(8),
64 .BR pivot_root(2),
65 .BR umount(8)