If we have a ZFS swap device and we discover that it is not big enough then we have two options to add more swap.
The supported option is to create a new swap device and then activate it with swap -a. The disadvantage of this option is that we have to add the new device to the vfstab which makes the file and future swap -l outputs untidy as we will now have swap and swap2.
The unsupported option is to grow the existing swap and then add the new area as a second swap device. No editing of the vfstab is required and after the reboot we only have one swap device.
Here are the steps for the second option. Note that the offset is calculated by (swaplo + blocks);
# swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,3 16 4194288 4194288
# zfs list rpool/swap
NAME USED AVAIL REFER MOUNTPOINT
rpool/swap 2G 102G 791M -
# zfs set volsize=4G rpool/swap
# env NOINUSE_CHECK=1 swap -a /dev/zvol/dsk/rpool/swap $((16+4194288))
# swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,3 16 4194288 4194288
/dev/zvol/dsk/rpool/swap 256,3 4194304 4194304 4194304
Note that if we want to remove this second device and resize the volume back down then we can use the "/usr/sbin/swap -d swapname [swaplow]" syntax and then resize the volume. Obviously this only works before we reboot.
# swap -d /dev/zvol/dsk/rpool/swap 4194304
# swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,3 16 4194288 4194288
# zfs set volsize=2G rpool/swap
Monday, January 31, 2011
Subscribe to:
Comments (Atom)
