2009-07-29 05:23:52 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: zvol
|
|
|
|
# REQUIRE: hostid
|
2016-05-15 04:38:50 +00:00
|
|
|
# BEFORE: dumpon
|
2009-07-29 05:23:52 +00:00
|
|
|
# KEYWORD: nojail
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="zvol"
|
2016-04-23 16:10:54 +00:00
|
|
|
desc="Activate swap on ZVOLs"
|
2009-07-29 05:23:52 +00:00
|
|
|
rcvar="zfs_enable"
|
|
|
|
start_cmd="zvol_start"
|
|
|
|
stop_cmd="zvol_stop"
|
|
|
|
required_modules="zfs"
|
|
|
|
|
|
|
|
zvol_start()
|
|
|
|
{
|
|
|
|
# Enable swap on ZVOLs with property org.freebsd:swap=on.
|
2016-04-24 10:52:59 +00:00
|
|
|
zfs list -H -o org.freebsd:swap,name -t volume |
|
2009-07-29 05:23:52 +00:00
|
|
|
while read state name; do
|
|
|
|
case "${state}" in
|
2016-04-24 10:52:59 +00:00
|
|
|
([oO][nN])
|
2009-07-29 05:23:52 +00:00
|
|
|
swapon /dev/zvol/${name}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
zvol_stop()
|
|
|
|
{
|
|
|
|
# Disable swap on ZVOLs with property org.freebsd:swap=on.
|
2016-04-24 10:52:59 +00:00
|
|
|
zfs list -H -o org.freebsd:swap,name -t volume |
|
2009-07-29 05:23:52 +00:00
|
|
|
while read state name; do
|
|
|
|
case "${state}" in
|
2016-04-24 10:52:59 +00:00
|
|
|
([oO][nN])
|
2009-07-29 05:23:52 +00:00
|
|
|
swapoff /dev/zvol/${name}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|