rageek

A place for Unix Thoughts and Ideas

Adding Swap To a Solaris Server

Unless you spend your time only managing database server or have dedicated an entire disk for swap, eventually you are most likely going to need to increase your swap to handle a overzellous Java applications.

I had to do this the other night and figured it would be good to post the process

If you are on a ZFS root,  while you can technically resize the zfs volume, Solaris will not pick up the changes without a reboot.

You could always drop the swap volume and re-add it, but if you are having to increase swap, that is probably a really bad idea.

So Here is a quick a dirty procedure for adding ZFS swap to a system, this system had less than 2GB of swap left and was starting to get sluggish

root@testserver $ swap -s
total: 47704096k bytes allocated + 10022424k reserved = 57726520k used, 1726824k available
root@testserver # swap -l
swapfile             dev  swaplo blocks   free
/dev/zvol/dsk/rpool/swap 256,1      16 16779248 16779248
root@testserver # zfs create -V 20G rpool/swap_1
root@testserver # swap -a /dev/zvol/dsk/rpool/swap_1
jflaster@testserver $ swap -l
swapfile             dev  swaplo blocks   free
/dev/zvol/dsk/rpool/swap 256,1      16 16779248 16779248
/dev/zvol/dsk/rpool/swap_1 256,3      16 41943024 41943024
root@testserver # swap -s
total: 47697768k bytes allocated + 10022152k reserved = 57719920k used, 22704208k available
echo "/dev/zvol/dsk/rpool/swap_1      -       -       swap    -       no      -" >> /etc/vfstab

Here is the procedure on UFS:

root@testserver:~# mkfile 20G /var/DO_NOT_DELETE_swapfile1
root@sanbapsunadm3 # swap -a  /var/DO_NOT_DELETE_swapfile1
root@sanbapsunadm3 # swap -l
swapfile             dev  swaplo blocks   free
/dev/md/dsk/d10     85,10     16 16780208 16780208
/var/DO_NOT_DELETE_swapfile1  -       16 41943024 41943024
root@testserver:~# echo "/var/DO_NOT_DELETE_swapfile1    -         -       swap    -       no      -" >> /etc/vfstab
Advertisements

2 responses to “Adding Swap To a Solaris Server

  1. bradhudsonjr May 14, 2012 at 7:30 pm

    The recognition of a resize on rpool/swap was fixed in Solaris 10. You may need to upgrade your zpool/zfs versions to properly get support for it (zpool upgrade/zfs upgrade).

    • jflaster May 14, 2012 at 8:13 pm

      Let me know if it works differently on your system, if it does Let me know the patch number.

      Just tried it on one of my test boxes running u10 w/147440-15:

      root@testserver # zfs get volsize rpool/swap
      NAME        PROPERTY  VALUE    SOURCE
      rpool/swap  volsize   16G      local
      root@testserver # swap -l 
      swapfile             dev  swaplo blocks   free
      /dev/zvol/dsk/rpool/swap 256,1      16 33554416 33554416
      
      root@testserver # zfs set volsize=32G rpool/swap
      root@testserver # swap -l
      swapfile             dev  swaplo blocks   free
      /dev/zvol/dsk/rpool/swap 256,1      16 33554416 33554416
      
      root@testserver # swap -d /dev/zvol/dsk/rpool/swap
      root@testserver # swap -a /dev/zvol/dsk/rpool/swap
      root@testserver # swap -l
      swapfile             dev  swaplo blocks   free
      /dev/zvol/dsk/rpool/swap 256,1      16 67108848 67108848
      

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: