UNIX Consulting and Expertise
Golden Apple Enterprises Ltd. » Archive of 'Mar, 2010'

Growing swap on a ZFS filesystem 1 comment

Recently I had to tackle a badly installed Solaris machine which hadn’t been configured with enough swap space. Luckily it had been built with a ZFS root filesystem, which made dealing with this a lot less painful.

First of all we need to get the details of our current swap setup:

bash-3.00# swap -l
swapfile             dev  swaplo blocks   free
/dev/zvol/dsk/rpool/swap 256,2      16 4194288 4194288

New step is to increase the size of the ZFS ‘filesystem’ under the root pool (here called the default, rpool).

bash-3.00# zfs set volsize=4G rpool/swap

Once the filesystem size has been increased, we need to actually add it as swap. The normal swap command will do this – we just need to make sure we’re pointing it at the correct ZFS device:

bash-3.00# env NOINUSE_CHECK=1 swap -a /dev/zvol/dsk/rpool/swap $((8+4194288))

Let’s just check the status via ZFS:

bash-3.00# zfs list rpool/swap
NAME         USED  AVAIL  REFER  MOUNTPOINT
rpool/swap     4G  3.16G  2.03G  -

And finally we can see the new swap space we’ve just added:

bash-3.00# swap -l
swapfile             dev  swaplo blocks   free
/dev/zvol/dsk/rpool/swap 256,2      16 4194288 4194288
/dev/zvol/dsk/rpool/swap 256,2  4194304 4194304 4194304

A simple handful of commands, and no downtime – adding extra swap space using ZFS on Solaris is pretty painless. In another post I’ll explore how to grow ZFS filesystems like /var.

Top of page / Subscribe to new Entries (RSS)