Add a switch to make all jails use its own zfs by default, also provide a parameter to specify default zfs options
This commit is contained in:
parent
5f9fafd80f
commit
6a629c1634
15
ezjail-admin
15
ezjail-admin
@ -392,6 +392,9 @@ parse_gbde_attach_args () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_for_zfs () {
|
check_for_zfs () {
|
||||||
|
# check if the ezjail zfs has been specified
|
||||||
|
[ -n "${ezjail_jailzfs}" ] || exerr "Error: The variable ezjail_jailzfs needs to point a zfs ezjail can work in.\n Set it in your ezjail.conf."
|
||||||
|
|
||||||
# check the ZFS version
|
# check the ZFS version
|
||||||
_zfs_version=`sysctl -nq vfs.zfs.version.spa`
|
_zfs_version=`sysctl -nq vfs.zfs.version.spa`
|
||||||
[ -z "${_zfs_version}" -o "${_zfs_version}" -lt 13 ] && exerr "Error: ZFS is not loaded or your ZFS version is not supported."
|
[ -z "${_zfs_version}" -o "${_zfs_version}" -lt 13 ] && exerr "Error: ZFS is not loaded or your ZFS version is not supported."
|
||||||
@ -471,14 +474,18 @@ create)
|
|||||||
# we need at least a name and an ip for new jail
|
# we need at least a name and an ip for new jail
|
||||||
[ "${ezjail_name}" -a "${ezjail_ips}" -a $# -eq 2 ] || exerr ${ezjail_usage_create}
|
[ "${ezjail_name}" -a "${ezjail_ips}" -a $# -eq 2 ] || exerr ${ezjail_usage_create}
|
||||||
|
|
||||||
# check for an active ZFS zpool
|
|
||||||
[ "${ezjail_imagetype}" = "zfs" ] && check_for_zpool
|
|
||||||
|
|
||||||
# check for sanity of settings concerning the image feature
|
# check for sanity of settings concerning the image feature
|
||||||
if [ "${ezjail_imagetype}" != "zfs" ]; then
|
if [ "${ezjail_imagetype}" != "zfs" ]; then
|
||||||
[ -z "${ezjail_imagetype}" -o "${ezjail_exists}" -o "${ezjail_imagesize}" ] || exerr "Error: Image jails need an image size."
|
[ -z "${ezjail_imagetype}" -o "${ezjail_exists}" -o "${ezjail_imagesize}" ] || exerr "Error: Image jails need an image size."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If user wants jails to be in zfs by default, and did not override it on
|
||||||
|
# the command line, make the jail a zfs one
|
||||||
|
[ "${ezjail_use_zfs_for_jails}" = "YES" -a ! "${ezjail_imagetype}" ] && ezjail_imagetype=zfs
|
||||||
|
|
||||||
|
# check for an active ZFS zpool
|
||||||
|
[ "${ezjail_imagetype}" = "zfs" ] && check_for_zpool
|
||||||
|
|
||||||
# check for a sane image type
|
# check for a sane image type
|
||||||
case ${ezjail_imagetype} in ""|simple|bde|eli|zfs) ;; *) exerr ${ezjail_usage_create};; esac
|
case ${ezjail_imagetype} in ""|simple|bde|eli|zfs) ;; *) exerr ${ezjail_usage_create};; esac
|
||||||
|
|
||||||
@ -617,7 +624,7 @@ create)
|
|||||||
;;
|
;;
|
||||||
zfs)
|
zfs)
|
||||||
if [ -z "${ezjail_exists}" ]; then
|
if [ -z "${ezjail_exists}" ]; then
|
||||||
[ -n "${ezjail_imagesize}" ] && ezjail_zfs_jail_properties="-o quota=${ezjail_imagesize} -o compression=lzjb"
|
[ "${ezjail_imagesize}" ] && ezjail_zfs_jail_properties="${ezjail_zfs_jail_properties} -o quota=${ezjail_imagesize}"
|
||||||
[ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}"
|
[ -d "${ezjail_jaildir}/${ezjail_hostname}" ] && exerr "Error: Could not create jail root mount point ${ezjail_rootdir}"
|
||||||
|
|
||||||
/sbin/zfs create -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properties} ${ezjail_jailzfs}/${ezjail_hostname}
|
/sbin/zfs create -o mountpoint=${ezjail_rootdir} ${ezjail_zfs_jail_properties} ${ezjail_jailzfs}/${ezjail_hostname}
|
||||||
|
@ -52,7 +52,10 @@
|
|||||||
|
|
||||||
# Setting this to YES will start to manage the basejail and newjail in ZFS
|
# Setting this to YES will start to manage the basejail and newjail in ZFS
|
||||||
# ezjail_use_zfs="YES"
|
# ezjail_use_zfs="YES"
|
||||||
|
# Setting this to YES will manage ALL new jails in their own zfs
|
||||||
|
# ezjail_use_zfs_for_jails="YES"
|
||||||
# The name of the ZFS ezjail should create jails on, it will be mounted at the ezjail_jaildir
|
# The name of the ZFS ezjail should create jails on, it will be mounted at the ezjail_jaildir
|
||||||
# ezjail_jailzfs="tank/ezjail"
|
# ezjail_jailzfs="tank/ezjail"
|
||||||
# ADVANCED, be very careful!
|
# ADVANCED, be very careful!
|
||||||
# ezjail_zfs_properties="-o compression=lzjb -o atime=off"
|
# ezjail_zfs_properties="-o compression=lzjb -o atime=off"
|
||||||
|
# ezjail_zfs_jail_properties="-o dedup=on"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user