Seth Woolley's Man Viewer

Manual for pivot_root - man 8 pivot_root

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

PIVOT_ROOT(8)                Maintenance Commands                PIVOT_ROOT(8)

       pivot_root(2,8) - change the root file(1,n) system

       pivot_root(2,8) new_root put_old

       pivot_root(2,8)  moves  the  root  file(1,n) system of the current process to the
       directory put_old and makes new_root the new root file(1,n)  system.   Since
       pivot_root(2,8)(8)  simply  calls pivot_root(2,8)(2), we refer to the man(1,5,7) page of
       the latter for further details.

       Note that, depending on the implementation of pivot_root(2,8), root and  cwd
       of  the  caller  may or may not change. The following is a sequence for
       invoking pivot_root(2,8) that works in(1,8) either case, assuming that pivot_root(2,8)
       and chroot(1,2) are in(1,8) the current PATH:

       cd new_root
       pivot_root(2,8) . put_old
       exec(3,n,1 builtins) chroot(1,2) . command

       Note that chroot(1,2) must be available under the old root and under the new
       root, because pivot_root(2,8) may or may not  have  implicitly  changed  the
       root directory of the shell.

       Note  that  exec(3,n,1 builtins) chroot(1,2) changes the running executable, which is neces-
       sary if(3,n) the old root directory should be  unmounted  afterwards.   Also
       note that standard input, output, and error(8,n) may still point to a device
       on the old root file(1,n) system,  keeping  it  busy.  They  can  easily  be
       changed  when  invoking  chroot(1,2) (see below; note the absence of leading
       slashes to make it work whether pivot_root(2,8) has changed the shell's root
       or not).

       Change the root file(1,n) system to /dev/hda1 from an interactive shell:

       mount(2,8) /dev/hda1 /new-root
       cd /new-root
       pivot_root(2,8) . old-root
       exec(3,n,1 builtins) chroot(1,2) . sh <dev/console(4,n) >dev/console(4,n) 2>&1
       umount /old-root

       Mount  the new root file(1,n) system over NFS from and run

       ifconfig lo up   # for portmap
       # configure Ethernet or such
       portmap   # for lockd (implicitly started by mount(2,8))
       mount(2,8) -o ro /mnt
       killall portmap   # portmap keeps old root busy
       cd /mnt
       pivot_root(2,8) . old_root
       exec(3,n,1 builtins) chroot(1,2) . sh -c 'umount /old_root; exec(3,n,1 builtins) /sbin/init' \
         <dev/console(4,n) >dev/console(4,n) 2>&1

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

Linux                            Feb 23, 2000                    PIVOT_ROOT(8)

References for this manual (incoming links)