add swap partition support
diff --git a/README.rst b/README.rst
index a9652c1..4b06443 100644
--- a/README.rst
+++ b/README.rst
@@ -493,6 +493,19 @@
device: /swapfile
size: 1024
+Linux with partition swap
+
+.. code-block:: yaml
+
+ linux:
+ storage:
+ enabled: true
+ swap:
+ partition:
+ enabled: true
+ engine: partition
+ device: /dev/vg0/swap
+
LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
.. code-block:: yaml
diff --git a/linux/storage/swap.sls b/linux/storage/swap.sls
index 81694e9..ccae5f6 100644
--- a/linux/storage/swap.sls
+++ b/linux/storage/swap.sls
@@ -5,7 +5,27 @@
{%- if swap.enabled %}
-{%- if swap.engine == 'file' %}
+{%- if swap.engine == 'partition' %}
+
+linux_create_swap_partition_{{ swap.device }}:
+ cmd.run:
+ - name: 'mkswap {{ swap.device }}'
+ - creates: {{ swap.device }}
+
+linux_set_swap_partition_{{ swap.device }}:
+ cmd.run:
+ - name: 'swapon {{ swap.device }}'
+ - unless: grep $(readlink -f /dev/vg0/swap) /proc/swaps
+ - require:
+ - cmd: linux_create_swap_partition_{{ swap.device }}
+
+{{ swap.device }}:
+ mount.swap:
+ - persist: True
+ - require:
+ - cmd: linux_set_swap_partition_{{ swap.device }}
+
+{%- elif swap.engine == 'file' %}
linux_create_swap_file_{{ swap.device }}:
cmd.run: