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