Skip to content

Instantly share code, notes, and snippets.

@yebyen
Last active April 13, 2016 02:10
Show Gist options
  • Save yebyen/e3ec488c565b39e8e65fe4a670b91a71 to your computer and use it in GitHub Desktop.
Save yebyen/e3ec488c565b39e8e65fe4a670b91a71 to your computer and use it in GitHub Desktop.
patch for deis/deis to create a swap file
diff --git a/contrib/coreos/user-data.example b/contrib/coreos/user-data.example
index 59f4f46..f8ed383 100644
--- a/contrib/coreos/user-data.example
+++ b/contrib/coreos/user-data.example
@@ -24,6 +24,31 @@ coreos:
command: start
- name: fleet.service
command: start
+ - name: swapon.service
+ command: start
+ enable: true
+ content: |
+ [Unit]
+ Description=Turn on swap
+
+ [Service]
+ Type=oneshot
+ Environment="SWAPFILE=/4GiB.swap"
+ RemainAfterExit=true
+ ExecStartPre=/usr/bin/touch ${SWAPFILE}
+ ExecStartPre=/usr/bin/fallocate -l 4096m ${SWAPFILE}
+ ExecStartPre=/usr/bin/chmod 600 ${SWAPFILE}
+ ExecStartPre=/usr/sbin/mkswap ${SWAPFILE}
+ ExecStartPre=/usr/sbin/losetup -f ${SWAPFILE}
+ ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
+ ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
+ ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
+
+ [Install]
+ WantedBy=multi-user.target
+
+ [X-Fleet]
+ Global=true
- name: docker-tcp.socket
command: start
enable: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment