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