1PIVOT_ROOT(8)                Maintenance Commands                PIVOT_ROOT(8)
2
3
4

NAME

6       pivot_root - change the root file system
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

EXAMPLES

39       Change the root file system to /dev/hda1 from an interactive shell:
40
41       mount /dev/hda1 /new-root
42       cd /new-root
43       pivot_root . old-root
44       exec chroot . sh <dev/console >dev/console 2>&1
45       umount /old-root
46
47       Mount  the new root file system over NFS from 10.0.0.1:/my_root and run
48       init:
49
50       ifconfig lo 127.0.0.1 up   # for portmap
51       # configure Ethernet or such
52       portmap   # for lockd (implicitly started by mount)
53       mount -o ro 10.0.0.1:/my_root /mnt
54       killall portmap   # portmap keeps old root busy
55       cd /mnt
56       pivot_root . old_root
57       exec chroot . sh -c 'umount /old_root; exec /sbin/init' \
58         <dev/console >dev/console 2>&1
59

SEE ALSO

61       chroot(1), mount(8), pivot_root(2), umount(8)
62

AVAILABILITY

64       The pivot_root command is part of  the  util-linux-ng  package  and  is
65       available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
66
67
68
69Linux                            Feb 23, 2000                    PIVOT_ROOT(8)
Impressum