]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/pivot_root.8.adoc
hardlink: use xcalloc rather than xmalloc
[thirdparty/util-linux.git] / sys-utils / pivot_root.8.adoc
1 //po4a: entry man manual
2 = pivot_root(8)
3 :doctype: manpage
4 :man manual: System Administration
5 :man source: util-linux {release-version}
6 :page-layout: base
7 :command: pivot_root
8
9 == NAME
10
11 pivot_root - change the root filesystem
12
13 == SYNOPSIS
14
15 *pivot_root* _new_root_ _put_old_
16
17 == DESCRIPTION
18
19 *pivot_root* moves the root file system of the current process to the directory _put_old_ and makes _new_root_ the new root file system. Since *pivot_root*(8) simply calls *pivot_root*(2), we refer to the man page of the latter for further details.
20
21 Note that, depending on the implementation of *pivot_root*, root and current working directory of the caller may or may not change. The following is a sequence for invoking *pivot_root* that works in either case, assuming that *pivot_root* and *chroot* are in the current *PATH*:
22
23 ....
24 cd new_root
25 pivot_root . put_old
26 exec chroot . command
27 ....
28
29 Note that *chroot* must be available under the old root and under the new root, because *pivot_root* may or may not have implicitly changed the root directory of the shell.
30
31 Note that *exec chroot* changes the running executable, which is necessary if the old root directory should be unmounted afterwards. Also note that standard input, output, and error may still point to a device on the old root file system, keeping it busy. They can easily be changed when invoking *chroot* (see below; note the absence of leading slashes to make it work whether *pivot_root* has changed the shell's root or not).
32
33 == OPTIONS
34
35 include::man-common/help-version.adoc[]
36
37 == EXAMPLE
38
39 Change the root file system to _/dev/hda1_ from an interactive shell:
40
41 ....
42 mount /dev/hda1 /new-root
43 cd /new-root
44 pivot_root . old-root
45 exec chroot . sh <dev/console >dev/console 2>&1
46 umount /old-root
47 ....
48
49 Mount the new root file system over NFS from 10.0.0.1:/my_root and run *init*:
50
51 ....
52 ifconfig lo 127.0.0.1 up # for portmap
53 # configure Ethernet or such
54 portmap # for lockd (implicitly started by mount)
55 mount -o ro 10.0.0.1:/my_root /mnt
56 killall portmap # portmap keeps old root busy
57 cd /mnt
58 pivot_root . old_root
59 exec chroot . sh -c 'umount /old_root; exec /sbin/init' \
60 <dev/console >dev/console 2>&1
61 ....
62
63 == SEE ALSO
64
65 *chroot*(1),
66 *pivot_root*(2),
67 *mount*(8),
68 *switch_root*(8),
69 *umount*(8)
70
71 include::man-common/bugreports.adoc[]
72
73 include::man-common/footer.adoc[]
74
75 ifdef::translation[]
76 include::man-common/translation.adoc[]
77 endif::[]