1chroot(1M) System Administration Commands chroot(1M)
2
3
4
6 chroot - change root directory for a command
7
9 /usr/sbin/chroot newroot command
10
11
13 The chroot utility causes command to be executed relative to newroot.
14 The meaning of any initial slashes (/) in the path names is changed to
15 newroot for command and any of its child processes. Upon execution, the
16 initial working directory is newroot.
17
18
19 Notice that redirecting the output of command to a file,
20
21 chroot newroot command >x
22
23
24
25
26 will create the file x relative to the original root of command, not
27 the new one.
28
29
30 The new root path name is always relative to the current root. Even if
31 a chroot is currently in effect, the newroot argument is relative to
32 the current root of the running process.
33
34
35 This command can be run only by the super-user.
36
38 The exit status of chroot is the return value of command.
39
41 Example 1 Using the chroot Utility
42
43
44 The chroot utility provides an easy way to extract tar files (see
45 tar(1)) written with absolute filenames to a different location. It is
46 necessary to copy the shared libraries used by tar (see ldd(1)) to the
47 newroot filesystem.
48
49
50 example# mkdir /tmp/lib; cd /lib
51 example# cp ld.so.1 libc.so.1 libcmd.so.1 libdl.so.1 \
52 libsec.so.1 /tmp/lib
53 example# cp /usr/bin/tar /tmp
54 example# dd if=/dev/rmt/0 | chroot /tmp tar xvf -
55
56
57
59 See attributes(5) for descriptions of the following attributes:
60
61
62
63
64 ┌─────────────────────────────┬─────────────────────────────┐
65 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
66 ├─────────────────────────────┼─────────────────────────────┤
67 │Availability │SUNWcsu │
68 └─────────────────────────────┴─────────────────────────────┘
69
71 cd(1), tar(1), chroot(2), ttyname(3C), attributes(5)
72
74 Exercise extreme caution when referencing device files in the new root
75 file system.
76
77
78 References by routines such as ttyname(3C) to stdin, stdout, and stderr
79 will find that the device associated with the file descriptor is
80 unknown after chroot is run.
81
82
83
84SunOS 5.11 15 Dec 2003 chroot(1M)