zvol revision 195938
1195938Spjd#!/bin/sh 2195938Spjd# 3195938Spjd# $FreeBSD: head/etc/rc.d/zvol 195938 2009-07-29 05:23:52Z pjd $ 4195938Spjd# 5195938Spjd 6195938Spjd# PROVIDE: zvol 7195938Spjd# REQUIRE: hostid 8195938Spjd# BEFORE: fsck 9195938Spjd# KEYWORD: nojail 10195938Spjd 11195938Spjd. /etc/rc.subr 12195938Spjd 13195938Spjdname="zvol" 14195938Spjdrcvar="zfs_enable" 15195938Spjdstart_cmd="zvol_start" 16195938Spjdstop_cmd="zvol_stop" 17195938Spjdrequired_modules="zfs" 18195938Spjd 19195938Spjdzvol_start() 20195938Spjd{ 21195938Spjd zfs volinit 22195938Spjd # Enable swap on ZVOLs with property org.freebsd:swap=on. 23195938Spjd zfs list -H -o org.freebsd:swap,name -t volume | \ 24195938Spjd while read state name; do 25195938Spjd case "${state}" in 26195938Spjd [oO][nN]) 27195938Spjd swapon /dev/zvol/${name} 28195938Spjd ;; 29195938Spjd esac 30195938Spjd done 31195938Spjd} 32195938Spjd 33195938Spjdzvol_stop() 34195938Spjd{ 35195938Spjd # Disable swap on ZVOLs with property org.freebsd:swap=on. 36195938Spjd zfs list -H -o org.freebsd:swap,name -t volume | \ 37195938Spjd while read state name; do 38195938Spjd case "${state}" in 39195938Spjd [oO][nN]) 40195938Spjd swapoff /dev/zvol/${name} 41195938Spjd ;; 42195938Spjd esac 43195938Spjd done 44195938Spjd zfs volfini 45195938Spjd} 46195938Spjd 47195938Spjdload_rc_config $name 48195938Spjdrun_rc_command "$1" 49