1PIVOT_ROOT(8)                System Administration               PIVOT_ROOT(8)
2
3
4

NAME

6       pivot_root - change the root filesystem
7

SYNOPSIS

9       pivot_root new_root put_old
10

DESCRIPTION

12       pivot_root  moves  the  root  file system of the current process to the
13       directory put_old and makes new_root the new root file  system.   Since
14       pivot_root(8)  simply  calls pivot_root(2), we refer to the man page of
15       the latter for further details.
16
17       Note that, depending on the implementation of pivot_root, root and  cwd
18       of  the  caller  may or may not change. The following is a sequence for
19       invoking pivot_root that works in either case, assuming that pivot_root
20       and chroot are in the current PATH:
21
22       cd new_root
23       pivot_root . put_old
24       exec chroot . command
25
26       Note that chroot must be available under the old root and under the new
27       root, because pivot_root may or may not  have  implicitly  changed  the
28       root directory of the shell.
29
30       Note  that  exec chroot changes the running executable, which is neces‐
31       sary if the old root directory should be  unmounted  afterwards.   Also
32       note that standard input, output, and error may still point to a device
33       on the old root file system,  keeping  it  busy.  They  can  easily  be
34       changed  when  invoking  chroot (see below; note the absence of leading
35       slashes to make it work whether pivot_root has changed the shell's root
36       or not).
37

OPTIONS

39       -V, --version
40              Display version information and exit.
41
42       -h, --help
43              Display help text and exit.
44

EXAMPLES

46       Change the root file system to /dev/hda1 from an interactive shell:
47
48       mount /dev/hda1 /new-root
49       cd /new-root
50       pivot_root . old-root
51       exec chroot . sh <dev/console >dev/console 2>&1
52       umount /old-root
53
54       Mount  the new root file system over NFS from 10.0.0.1:/my_root and run
55       init:
56
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

SEE ALSO

68       chroot(1), pivot_root(2), mount(8), switch_root(8), umount(8)
69

AVAILABILITY

71       The pivot_root command is part of the util-linux package and is  avail‐
72       able from https://www.kernel.org/pub/linux/utils/util-linux/.
73
74
75
76util-linux                        August 2011                    PIVOT_ROOT(8)
Impressum