Adjusting the Sizes of ZFS Swap and Dump Devices
After installation, you might need to adjust the size of swap and dump devices after installation. Or you might need to recreate the swap and dump volumes.
By default, when you specify n blocks for the swap size, if the device is not a ZFS volume, the first page of the swap file is automatically skipped. Thus, the actual size that is assigned is n-1 blocks. To configure the swap file size differently, use the swaplow
option with the swap
command. For more information about the options for the swap
command, see the swap
(8) man page.
The following examples show how to adjust existing swap and dump devices under different circumstances.
Example 6-10 Resetting the Dump Device volsize
Property
Note that resizing a large dump device can be a time-consuming process.
$ zfs set volsize=2G rpool/dump $ zfs get volsize rpool/dump NAME PROPERTY VALUE SOURCE rpool/dump volsize 2G -
Example 6-11 Resizing the Swap Volume for Immediate Use
This example shows how to adjust the size of the swap volume.
$ swap -l swapfile dev swaplo blocks free encrypted /dev/zvol/dsk/rpool/swap 230,5 0 2097152 2097152 yes $ zfs get volsize rpool/swap NAME PROPERTY VALUE SOURCE rpool/swap volsize 1G local $ zfs set volsize=2g rpool/swap $ swap -l swapfile dev swaplo blocks free encrypted /dev/zvol/dsk/rpool/swap 230,5 0 2097152 2097152 yes /dev/zvol/dsk/rpool/swap 230,5 2097152 2097152 2097152 yes
You will see two swap entries temporarily, but you will have access to the extended swap space.
Example 6-12 Shrinking the Size of a Swap Device
This example shows the steps you must take to shrink the size of a swap device.
While you can grow swap and dump devices, you cannot shrink them directly.
The following example commands show how to shrink the rpool/swap
swap device.
Determine the size of the rpool/swap
swap device.
# zfs get volsize rpool/swap
NAME PROPERTY VALUE SOURCE
rpool/swap volsize 4G local
Delete the rpool/swap
swap device.
# swap -td rpool/swap
Shrink the zpool/swap
device from 4 Gbytes to 2 Gbytes.
# zfs set -f volsize=2G rpool/swap
Reconfigure the rpool/swap
swap device.
# swap -a rpool/swap