1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# PROVIDE: zvol 7# REQUIRE: zpool 8# KEYWORD: nojail 9 10. /etc/rc.subr 11 12name="zvol" 13desc="Activate swap on ZVOLs" 14rcvar="zfs_enable" 15start_cmd="zvol_start" 16stop_cmd="zvol_stop" 17required_modules="zfs" 18 19zvol_start() 20{ 21 # Enable swap on ZVOLs with property org.freebsd:swap=on. 22 zfs list -H -o org.freebsd:swap,name -t volume | 23 while read state name; do 24 case "${state}" in 25 ([oO][nN]) 26 swapon /dev/zvol/${name} 27 ;; 28 esac 29 done 30} 31 32zvol_stop() 33{ 34 # Disable swap on ZVOLs with property org.freebsd:swap=on. 35 zfs list -H -o org.freebsd:swap,name -t volume | 36 while read state name; do 37 case "${state}" in 38 ([oO][nN]) 39 swapoff /dev/zvol/${name} 40 ;; 41 esac 42 done 43} 44 45load_rc_config $name 46run_rc_command "$1" 47