ZFS: swap on a ZVOL

Dan Naumov dan.naumov at gmail.com
Tue Jul 7 00:45:41 UTC 2009


Hello list.

As far as I know, using swap on top of a "non-trivial" filesystem like
ZFS is considered "unsupported", but it does in fact work. You can
create a ZVOL of arbitrary size (say, 4G) and then do the following:

zfs set org.freebsd:swap=on pool/swapvolname

to have /etc/rc.d/zfs enable swap on said ZVOL on every boot. You can
also do this in an ugly way: put swapon
/dev/zvol/<poolname>/<swapvolname> into your /etc/rc.local (without
having to pass the "org.freebsd:swap=on" option to the ZVOL).

Now the question remains, what kind of issues are expected to arise
when using swap on a ZVOL and is there any work going to in order to
resolve them? One of the issues mentioned is that ZVOL swap cannot
handle kernel dumps and another, more serious potential issue is a
race condition where "more swap is needed to swap". Assuming I have a
machine with 2gb ram, if I use a 4gb ZVOL swap, am I likely to run
into any serious issues assuming that under normal operation, the
system uses from none to very little swap?

- Sincerely,
Dan Naumov


More information about the freebsd-fs mailing list