Increase ZFS swap partition size

Solution 1:

From the output provided the swap is not part of the zpool/zvol. For example here is output from a machine which has Swap on ZFS:

My FSTAB:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/nuc--root-root /               xfs     noatime         0       0
# /boot was on /dev/sdb1 during installation
UUID=afd2054d-1ed3-498f-90de-b7d282bdab80 /boot           ext2    noatime,nodiratime 0       2
/dev/zvol/VMs/swap none swap discard 0 0
stratus@nuc:/$ sudo zpool list
NAME   SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
VMs    232G  79.0G   153G         -    61%    34%  1.00x  ONLINE  -

stratus@nuc:/$ sudo zpool status
  pool: VMs
 state: ONLINE
  scan: scrub repaired 0 in 0h21m with 0 errors on Sun Dec  8 00:45:29 2019
config:

    NAME                                  STATE     READ WRITE CKSUM
    VMs                                   ONLINE       0     0     0
      ata-faspeed_F710-250G_180116710082  ONLINE       0     0     0

errors: No known data errors

stratus@nuc:/$ sudo zfs list
NAME         USED  AVAIL  REFER  MOUNTPOINT
VMs         86.4G   138G    96K  none
VMs/images  77.7G   138G  77.7G  /var/lib/libvirt/images/
VMs/swap    8.50G   146G  1.09G  -

It is likely that 'rpool' is just a label on the partition and not refering to the ZFS volume.

If you would like to add SWAP to ZFS you can do this:

zfs create -V 8G -b $(getconf PAGESIZE) -o logbias=throughput -o sync=always -o primarycache=metadata -o com.sun:auto-snapshot=false rpool/swap
mkswap -f /dev/zvol/rpool/swap
swapon /dev/zvol/rpool/swap

In your FSTAB:

# IN FSTAB
/dev/zvol/rpool/swap none swap discard 0 0

Make sure to set the size as you feel appropriate