Manipulating swap space with ZFS

Let’s assume your OpenSolaris workstation doesn’t have enough swap space configured. In the old pre-ZFS days this was solvable by creating a swap file using mkfile(1M). With ZFS, things are a bit different: the resulting files aren’t usable as swap space anymore.

Check the available amount of swap space using zfs get:

zfs get volsize rpool/swap
NAME PROPERTY VALUE SOURCE
rpool/swap volsize 1G -

In my case, I have 1GB available swap space, I would like this to be a bit more. I can do this using zfs set:

zfs set volsize=4G rpool/swap
(no output)

Double check the outcome with zfs get:

zfs get volsize rpool/swap
NAME PROPERTY VALUE SOURCE
rpool/swap volsize 4G -

Happy swapping :)