# install FreeBDS in chroot



## antolap (Dec 3, 2017)

which is the easiest way to install FreeBSD in chroot directory?
Can I avoid to compile all from /usr/src?


I'd like to have the full base system inside /mychroot to do some tests.

Thanks


----------



## ShelLuser (Dec 3, 2017)

Easiest option is to simply unpack the archives. On the first live CD (disc1) you'll find a directory /usr/freebsd-dist which contains several archives that make up for the base system. Just extract the ones you need.

For example: on my server (which also uses jails) I simply copied base.txz, kernel.txz and lib32.txz to /opt/jails and whenever I need to install a new jail I can simply unpack those archives and I'm done.


----------



## rigoletto@ (Dec 3, 2017)

antolap 

Why don't you create a jail? It would be simpler, specially if using a tool like sysutils/iocell.


----------



## antolap (Dec 4, 2017)

lebarondemerde said:


> antolap
> 
> Why don't you create a jail?[/PORT].



Because, for what I have to do, I don't need limitations, with jails I have a lot of limitations (ping doesn't work as default etc)
Furthermore, iocell require ZFS and all my test computers are on UFS


----------



## mrclksr (Dec 4, 2017)

antolap said:


> Can I avoid to compile all from /usr/src?
> I'd like to have the full base system inside /mychroot to do some tests.



Assuming you want to install FreeBSD 11.1-RELEASE, amd64:

```
# sh -c 'BSDINSTALL_DISTSITE=ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/11.1-RELEASE bsdinstall jail /mychroot'
```


----------



## antolap (Dec 4, 2017)

THANKS!! exactly what I wanted to do

another question: when I chroot in a directory, which command can I use to see if I'm in chroot mode or on the real root (/) ?


----------



## mrclksr (Dec 4, 2017)

antolap said:


> another question: when I chroot in a directory, which command can I use to see if I'm in chroot mode or on the real root (/) ?


I don't know if there is such a command, but you could set the prompt of the chrooted root shell in /mychroot/root/.cshrc accordingly:

```
...
if ($?prompt) then
        # An interactive shell -- set some stuff up
        set prompt = "%N@CHROOT:%~ %# "
...
```
Or you could create an empty file in the chroot environment to indicate it's a chroot:

```
# touch /mychroot/CHROOT
```


----------

