Solaris 11 Swap File Location

Because of ZFS, working with Swap files in Solaris is surprisingly easy. On our development server, the OS is running on a single SSD device, and there is a large array of standard SATA disks attached to the AHCI controller. Although this system has plenty of RAM, swap space is important so we avoid OOM (out-of-memory) errors.

In order to move the swap file from the OS drive to the data drive:

zfs create -V 4G tank/swap
zfs set dedup=off tank/swap
swap -a /dev/zvol/dsk/tank/swap
swap -d /dev/zvol/dsk/rpool/swap

And then to make this change persistent across reboots, also edit the swap path in your /etc/vfstab.

/dev/zvol/dsk/tank/swap - - swap - no -

Using a shared swap device is fine for development and small office servers, but you should consider using dedicated and mirrored swap if this server will be under any serious load.

First find two physical disks for your new mirrored swap

root@gyro:~# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
0. c7t0d0
/pci@0,0/pci8086,3472@1f,2/disk@0,0
1. c7t1d0
/pci@0,0/pci8086,3472@1f,2/disk@1,0
2. c7t2d0
/pci@0,0/pci8086,3472@1f,2/disk@2,0
3. c7t3d0
/pci@0,0/pci8086,3472@1f,2/disk@3,0
4. c9t0d0
/pci@0,0/pci8086,25f7@2/pci8086,350c@0,3/pci11ab,11ab@2/disk@0,0
5. c9t1d0
/pci@0,0/pci8086,25f7@2/pci8086,350c@0,3/pci11ab,11ab@2/disk@1,0
6. c9t2d0
/pci@0,0/pci8086,25f7@2/pci8086,350c@0,3/pci11ab,11ab@2/disk@2,0
7. c9t3d0
/pci@0,0/pci8086,25f7@2/pci8086,350c@0,3/pci11ab,11ab@2/disk@3,0

Let’s pick the last two drives for our example

zpool create SWAP_ZPOOL mirror c9t2d0 c9t3d0
zfs set mountpoint=legacy SWAP_ZPOOL

Setting mountpoint=legacy will keep Solaris from mounting this drive automatically upon import. From here, follow the steps above to add this device to configure this device as swap and add to vfstab.

This entry was posted in Solaris. Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.
sitemap