Differences between current version and previous revision of KnowledgeBase/FreeBSD/JailDS.
Other diffs: Previous Major Revision, Previous Author
| Newer page: | version 3 | Last edited on Sunday, 13 January 2013 1:39:20 | by CyberLeo | |
| Older page: | version 2 | Last edited on Sunday, 13 January 2013 1:36:38 | by CyberLeo | Revert |
@@ -1,5 +1,5 @@
-This will delegate a dataset and its children to the given jail upon jail startup. The dataset will be unavailable to the host.
+This will delegate a dataset and its children to the given jail upon jail startup. The dataset will be unavailable to the host. Tested on FreeBSD 9.1-RELEASE
.
/etc/jail.conf:
<code brush="bash">
testnas {
@@ -18,9 +18,9 @@
jail_getid() {
[ "${1}" ] || return 1
jls -j "${1}" 2>/dev/null | grep -v '^[[:space:]]*JID' | while read jid ip host path
do
- echo ${jid}
+ echo "
${jid}" && break
done
}
jail="${1}"
current version
This will delegate a dataset and its children to the given jail upon jail startup. The dataset will be unavailable to the host. Tested on FreeBSD 9.1-RELEASE.
/etc/jail.conf:
testnas {
...
enforce_statfs = 1;
allow.mount;
allow.mount.zfs;
exec.prestart = "${base}/jailds ${name} testnas &";
}
jailds:
#!/bin/sh -e
jail_getid() {
[ "${1}" ] || return 1
jls -j "${1}" 2>/dev/null | grep -v '^[[:space:]]*JID' | while read jid ip host path
do
echo "${jid}" && break
done
}
jail="${1}"
dataset="${2}"
[ "${jail}" -a "${dataset}" ] || {
echo "Usage: jailds <jailname> <dataset>" >&2
exit 1
}
jid=""
for try in $(jot 20 1)
do
jid=$(jail_getid "${jail}")
[ "${jid}" ] && break
sleep 0.25
done
[ "${jid}" ] || {
echo "jailds: jail ${jail} never appeared" >&2
exit 1
}
zfs set jailed=on "${dataset}"
zfs jail "${jid}" "${dataset}"
jexec "${jail}" zfs mount -a
