Get the App
SLTechnology News&Howtos  ›  Development  › 

How to build chroot under Linux

Shulou Source: shulou.com Published: 2022-06-01 15:31:46 09月11日 Update

Editor to share with you how to build chroot under Linux. I hope you will get something after reading this article. Let's discuss it together.

Chroot is an operation in the unix system that changes its explicit root directory for the running software process and its child processes. A program that runs in this environment and sets the root directory through chroot cannot access files outside the specified root directory, read or change its contents.

Using yum, the installation package manager for Red Hat and CentOS systems, it is very easy to create a chroot environment. The steps are as follows:

\ 1. Create a new directory for chroot, for example:

Mkdir-p / var/jail/chroot

\ 2. To build a chroot environment, you first need to initialize the rpm database.

Mkdir-p / var/jail/chroot/var/lib/rpmrpm-- rebuilddb-- root=/var/jail/chroot

3. To save time, download the CentOS distribution manually and install it using the rpm command:

Wget http://mirror.centos.org/centos/6/os/i386/Packages/centos-release-6-0.el6.centos.5.i686.rpm (or whatever version you want to use) rpm-I-root=/var/jail/chroot-nodeps centos-release-6-0.el6.centos.5.i686.rpm

\ 4. Use the YUM tool to install the remaining packages of the CentOS distribution to the virtual chroot environment.

Yum-- installroot=/var/jail/chroot install-y rpm-build yum

\ 5. Finally, when the whole process is over (which will take a while), you can initialize chroot and try the new system:

Chroot / var/jail/chroot

If all goes well, you already have a relatively simple working chroot environment. However, if you want to actually use this environment, you need other important filesystem essential components, such as / proc and / dev. You can follow the instructions in the link above.

The translator added: the proc file loads the script to determine whether the proc file has been loaded, and calls mount without loading:

Mount-l | grep "/ var/jail/chroot/proc" > / dev/nullif [$?! = 0] then sudo mount-t proc chroot_proc / var/jail/chroot/proc/fi

After reading this article, I believe you have some understanding of "how to build chroot under Linux". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Environment file system root time article process release run important necessary content action command done actual tool manual instruction data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info Microsoft Redmi vpn