# Install packages source to chroot environment

Install your package binaries to the chroot directory to test in isolated an environment. This guide has you install a minimal Ubuntu `focal` distribution in the chroot directory where you can install programs and run processes in an isolated space.

### Install dependencies

```
sudo apt-get install debootstrap
```

### Create directory were to install chroot

```
mkdir ./chroot
```

### Create chroot environment

```
sudo debootstrap focal ./chroot/
```

### Mount required filesystems based on the requirements

```
sudo mount --bind /sys  ./chroot/sys/
sudo mount --bind /dev  ./chroot/dev/
sudo mount --bind /proc ./chroot/proc/
```

### Do Make install the source to chroot

```
make install DESTDIR=./chroot/
```

### Run your program in chroot environment

```
sudo chroot ./chroot/ <user-program>
```

### Explore the chroot environment

```
sudo chroot ./chroot/ bash
```

### Reference

<https://help.ubuntu.com/community/BasicChroot/\\>
<https://www.linode.com/docs/guides/use-chroot-for-testing-on-ubuntu/\\>
<https://askubuntu.com/questions/105840/install-program-from-source-to-chroot-env/><br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kribakarans.gitbook.io/howto/chroot/install_source_to_chroot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
