Thursday 22 October 2015

Adding or Changing Swap Space in an Oracle Solaris ZFS Root Environment

Adding or Changing Swap Space in an Oracle Solaris ZFS Root Environment
===============================================

A swap volume cannot be removed if it is in use. You can confirm if the current swap volume is in use by comparing the blocks identified in the blocks column and blocks identified in the free column. 

If the blocks in the two columns are equal, the swap area is not busy. 

# swap -l
swapfile                 dev   swaplo              blocks      free
/dev/zvol/dsk/rpool/swap 256,1      16 1058800 1058800

If the current swap area is not in use, you can resize the size of the current swap volume.

# zfs get volsize rpool/swap
NAME        PROPERTY  VALUE    SOURCE
rpool/swap  volsize   517M     -

# zfs set volsize=2g rpool/swap

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


If the current swap area is in use, you can add another swap volume.


# zfs create -V 2G rpool/swap2

Activate the second swap volume.

# swap -a /dev/zvol/dsk/rpool/swap2

# swap -l
swapfile                  dev  swaplo   blocks   free
/dev/zvol/dsk/rpool/swap  256,1      16 1058800 1058800
/dev/zvol/dsk/rpool/swap2 256,3      16 4194288 4194288