install FreeBDS in chroot

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
 
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.
 
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:
Code:
# sh -c 'BSDINSTALL_DISTSITE=ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/11.1-RELEASE bsdinstall jail /mychroot'
 
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 (/) ?
 
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:
Code:
...
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:
Code:
# touch /mychroot/CHROOT
 
Back
Top