FreeBSD + ZFS + Jails

FreeBSD+ZFS+Jails

## ZFS dataset for jail

#zfs create -o compress=lz4 zroot/jails/base101x64
#cd /var/tmp

## Fetch dist files

#fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/10.1-RELEASE/base.txz 
#fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/10.1-RELEASE/src.txz
#fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/10.1-RELEASE/lib32.txz 
#fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/10.1-RELEASE/games.txz

## untar distfiles to dataset

#tar -JxvC /jails/base101x64/ -f base.txz
#tar -JxvC /jails/base101x64/ -f src.txz
#tar -JxvC /jails/base101x64/ -f lib32.txz
#tar -JxvC /jails/base101x64/ -f games.txz

##Update Jail to patchlevel

#freebsd-update -b /jails/base101x64 fetch install

##config jail

#cp /etc/resolv.conf /jails/base101x64/etc/

#vi /jails/base101×64/etc/rc.conf

rpcbind_enable="NO"
font8x8="iso15-8x8"
font8x14="iso15-8x14"
font8x16="iso15-8x16"
keymap="german.iso"
sendmail_enable="NONE"
clear_tmp_enable="YES"
syslogd_flags="-ss"
sshd_enable="YES"

##chroot and config jail

#chroot /jails/base101x64
#newaliases
#passwd root
#pkg 
#exit

##Snapshot of jail

#zfs snapshot zroot/jails/base101x64@p6

##show all datasets

#zfs list -t all
...
zroot/jails/base101x64@p6                         0      -   770M  -
...
#cd /jails/base101x64/.zfs/snapshot
#ls -l
total 9
drwxr-xr-x  17 root  wheel  21 Nov 11 22:03 p6

##Clone des Snapshots for new jail
##Clones are related to snapshots
##you can not delete a snapshot if there is still a clonse based
##on the snapshots

#zfs clone zroot/jails/bas101x64@p6 zroot/jails/j_new

##Copy ZFS Datasets
##Not related to snapshot
##you can do this also copying the jail over the net with ssh

#zfs send -v zroot/jails/base101x64@p6| zfs receive zroot/jails/j_new
...
zroot/jails/j_new                        1.42G   157G  1.42G  /jails/j_new
...

About this entry