Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

cpp(1)

ls(1)

sh(1)

ctab(4)

chdir(2)

chroot(2)

chroot(8)  —  Maintenance

OSF

NAME

chroot − Changes the root directory of a command

SYNOPSIS

chroot directory [command]

DESCRIPTION

Only root can use the chroot command.  The chroot command changes the root directory from / to the specified directory when the command executes.  Consequently, the root of any path (as indicated by the first / (slash) in the pathname) changes to directory and is always relative to the current root.  Even if the chroot command is in effect, directory is relative to the current root of the running process. 

Several programs may not operate properly after chroot executes.  For example, the ls −l command fails to give user and group names if the current root location and the /etc/passwd file are on different file systems.  Utilities that depend on description files produced by the ctab command may also fail if the required description files are on a different file system than the new root file system.  You must ensure that all vital data files are present in the new root file system and that the relevant pathnames for the data files correspond to the new root file system. 

EXAMPLES

     1.To run a subshell with another file system as the root, enter:

chroot  /dev/ra1a  /bin/sh

This command specifies a change from the current root file system to /dev/ra1a while /bin/sh executes.  When /bin/sh executes, the original root file system is inaccessible.  The file system on /dev/ra1a must contain the standard directories of a root file system.  In particular, the shell looks for commands in /bin and /usr/bin on the new root file system.  Running the /bin/sh command creates a subshell, which runs as a separate process from the original shell.  Press <Ctrl-d> to exit the subshell and to return to the original shell.  This restores the environment of the original shell, including the meanings of the current directory (.) and the root directory (/). 

     2.To run a command in another root file system and save the output on the initial root file system, enter:

chroot  /dev/ra1a  /bin/cc  -E  /u/bob/prog.c  > prep.out

This command runs the /bin/cc command with /dev/ra1a as the specified root file system.  It compiles the /dev/ra1a/u/bob/prog.c file, reads the #include files from the /dev/ra1a/usr/include directory, and puts the compiled text in the prep.out file on the initial root file system. 

     3.To create a file relative to the original root rather than the new one, use this syntax and enter:

chroot  directory [command] > file

FILES

/usr/sbin/chroot
Specifies the command path.

CAUTIONS

If special files in the new root have different major and minor device numbers than the initial root directory, it is possible to overwrite the file system. 

RELATED INFORMATION

Commands:  cc(1), cpp(1), ls(1), sh(1)

Files:  ctab(4)

Functions:  chdir(2), chroot(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026