swap #2

  • By charmers
  • Latest version (#2)
  • precise
  • Stable
  • Edge


Generic swap charm subordinate. Intended to be a simple way to add
swap to your service units.

Subordinate Swap Charm

This charm aims to allow swap to be easily added to your juju service. Simply
attach this charm to your service, and you will have a swap file created. For
now, this is simply a lightweight wrapper around dphys-swapfile, as that
package has logic for sizing the swap partition and doing a swapon at boot,

For an interesting discussion of swap and it's usefullness (and/or lack
thereof) in production and scale-out services, see the following post. Be sure
to read all the comments and answers for unique perspectives:


Sample Deployment

# Simple case
juju deploy <principal charm>
juju deploy swap
juju add-relation <principal_charm> swap


# Create a larger swapfile across all your nodes
juju set swap maxsize=8000 size=4000

# Put the swapfile in a different path
juju set swap path=/var/swapfile


(string) The full path of the swapfile, defaults to /mnt/swap so that it will end up in the ephemeral partition on cloud instances.
(string) The maximum size of the swapfile, both computed and if specified with 'size'. This is passed directly along to dphys_swapfile.
(string) The size of the swapfile in megabytes. Uses the default algorithm in dphys-swapfile if you leave this blank.