How to increase swap space on OpenSolaris 2008.11

I’ve installed two OpenSolaris machines now, both of which have had benefited from greater performance by increasing swap space – in one case from 512Mb to 4Gb, since the laptop concerned (Acer Ferrari 3400) has only 1G of RAM but 70-odd gig of disk…

The method I used was as follows:

su - root # become root
swap -sh # find out how big your swapdevice is
zfs get volsize rpool/swap # find out how big your ZFS swapdevice is (should match above)
zfs set volsize=2G rpool/swap # enlarge it to (eg:) 2G, 2048M, however you wish to denote it
init 6 # reboot

Poke your system at your own risk, but I found the system considerably more responsive under load when swap was increased, even if it did not get used much…

(link to official sun documentation from where i got this information)

6 Replies to “How to increase swap space on OpenSolaris 2008.11”

  1. You don’t need to reboot or be root. You can add the extra space on as new swap device:

    cjg@brompton:~$ swap -l
    swapfile dev swaplo blocks free
    /dev/zvol/dsk/rpool/swap 182,1 8 4126712 4111472
    cjg@brompton:~$ pfexec zfs set volsize=4G rpool/swap
    cjg@brompton:~$ pfexec env NOINUSE_CHECK=1 swap -a /dev/zvol/dsk/rpool/swap $((8+4126712))
    cjg@brompton:~$ swap -l
    swapfile dev swaplo blocks free
    /dev/zvol/dsk/rpool/swap 182,1 8 4126712 4111472
    /dev/zvol/dsk/rpool/swap 182,1 4126720 4261888 4261888
    cjg@brompton:~$

    Being more “suppported” (the NOINUSE_CHECK is a bit on the edge) you can add a second device device and edit /etc/vfstab so it survives a reboot.

    As to the system being quicker with more unused swap that should be investigated as it should not happen.

  2. >You don’t need to reboot or be root. You can add the extra space on as new swap device

    ah, excellent; i was faintly annoyed that i resized the volume and the system stats did not reflect it immediately, but the i was doing it from the brute force and ignorance perspective.

    >As to the system being quicker with more unused swap that should be investigated as it should not happen.

    Yeah… that’s what I was thinking but i lack the resources to replicate it. Both systems are in use.

    That said – the Ferrari with 1G RAM and 512M swap (default, it seems) absolutely sucked when trying to install-all-packages (2.6G worth) – so i killed it and restarted with more swap and it was… acceptable.

    Thing is, in the former instance according to “top” only 310Mb of swap was used, so it wasn’t maxed-out…

  3. Note to self. File an RFE as none of this should be needed. If you grow, or shrink the volume it should just either do it or, in the case of shrinking when to much swap is being used fail.

    The performance issue is interesting. I wonder if we can measure a difference in a VirtualBox. That needs to be tried.

Leave a Reply

Your email address will not be published. Required fields are marked *