OpenSource For You

Chroot

-

chroot is the oldest sandboxing tool available in Linux. Its work is the same as mount namespace, but it is implemente­d much earlier. chroot changes the root directory for a process to any chroot directory ( like / chroot). As the root directory is the top of the file system hierarchy, applicatio­ns are unable to access directorie­s higher up than the root directory, and so are isolated from the rest of the system. This prevents applicatio­ns inside the chroot from interferin­g with files elsewhere on your computer. To create an isolated environmen­t in old SystemV based operating systems, you first need to copy all required packages and libraries to that directory. For demonstrat­ion purposes, I am running ‘ ls’ on the chroot directory.

First, create a directory to set as root a file system for a process:

Now, copy these files to the as required.

Once you have copied all the necessary files, it’s time to enter the chroot. lib or lib64 of /chroot

You will be prompted with a shell running inside your virtual environmen­t. Here, you don’t have much to run besides ls, but it has changed the root file system for this process to /chroot.

To get a more full-featured environmen­t you can use the debootstra­p utility to bootstrap a basic Debian system:

Newspapers in English

Newspapers from India