Comments (15)
FYI, to disable COW, I followed the instructions from: https://wiki.archlinux.org/index.php/Btrfs
So this is what I did:
sudo fallocate -l 2048m /2GiB.swap
sudo chmod 600 /2GiB.swap
sudo chattr +C /2GiB.swap
sudo mkswap /2GiB.swap
# ... added the swap.service unit to /var/lib/coreos-install/user_data ...
sudo reboot
After the reboot, I took a look at top
and saw the swap active and used
Swap: 2097148k total, 10144k used, 2087004k free, 245512k cached
Not sure if COW was actually disabled, nor do I know the actual performance gain.
Here is the units snippet in my user_data
file (per the above comments):
units:
- name: swap.service
command: start
content: |
[Unit]
Description=Turn on swap
[Service]
Type=oneshot
Environment="SWAPFILE=/2GiB.swap"
RemainAfterExit=true
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=local.target
Hope this helps.
- Fi
from docs.
This no longer works due to btrfs not being compatible with swap files. To make it work, I had to adjust the directions so that I created the file somewhere on btrfs (/4GiB.swap) and then used this unit file:
[Unit]
Description=Turn on swap
[Service]
Type=oneshot
Environment="SWAPFILE=/4GiB.swap"
RemainAfterExit=true
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=local.target
It's important to have the "RemainAfterExit" or else the Stop stanzas will be executed immediately.
They say that btrfs performs poorly in this situation, but if it's all you got...
from docs.
Should work a little better if you disable COW for the swap file when you create it.
from docs.
You may need to disable cow before using fallocate, you can only disable
cow on zero length files and off the top of my head I don't know if
fallocate counts towards that restriction or not.
On Aug 5, 2014 3:22 AM, "coderfi" [email protected] wrote:
FYI, to disable COW, I followed the instructions from:
https://wiki.archlinux.org/index.php/BtrfsSo this is what I did:
- sudo fallocate -l 2048m /2GiB.swap
- sudo chmod 600 /2GiB.swap
- sudo chattr +C /2GiB.swap
- sudo mkswap /2GiB.swap
- added the swap.service unit to /var/lib/coreos-install/user_data
- sudo reboot
- took a look at top and saw the swap active and used Swap: 2097148k
total, 10144k used, 2087004k free, 245512k cachedNot sure if COW was actually disabled, nor do I know the actual
performance gain.Here is the units snippet in my user_data file (per the above comments):
units:
name: swap.service
command: start
content: |
[Unit]
Description=Turn on swap[Service]
Type=oneshot
Environment="SWAPFILE=/2GiB.swap"
RemainAfterExit=true
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=local.target—
Reply to this email directly or view it on GitHub
#52 (comment).
from docs.
Thanks for this, worked like a charm for me. Is it possible to have the commands sudo fallocate...
also specified in the cloud-config
file instead of having to issue these manually? I see there is no runcmd
in a coreos cloud-config
file...
from docs.
@cboettig Here, I used the following service, which also executes fallocate: https://gist.github.com/romaninsh/118952ce61643914fb00
from docs.
Why not support the canonical swap configuration? http://cloudinit.readthedocs.org/en/latest/topics/examples.html#adjust-mount-points-mounted
Using this: https://gist.github.com/tsertkov/573d077012ae76443cbf but 50 lines of config just for a swapfile seems excessive.
from docs.
Related coreos/bugs#429 (comment).
from docs.
Are minimum of round(sqrt(RAM)) and maximum of twice the amount of RAM from https://help.ubuntu.com/community/SwapFaq recommendations we should follow on CoreOS?
from docs.
@joelchen most CoreOS instances don't use swap at all, so the minimum is zero. Canonical's recommended upper bound seems reasonable.
from docs.
@crawford What are the recommended use cases for no swap, as well as for using swap in CoreOS?
from docs.
@joelchen it depends heavily on how you plan on using the machine and the physical characteristics of the machine. I would suggest taking a look at what Linux recommends and then going with that.
from docs.
Do not try what @coderfi suggested, namely, disabling CoW to try to use a swapfile with btrfs, until you read that it is supported in the official documentation.
swap file support relies on one function that btrfs intentionally does not implement due to potential corruptions.
However:
A workaround, albeit with poor performance, is to mount a swap file via a loop device.
from docs.
Someone just mentioned losteup leads to lockups https://groups.google.com/d/msg/coreos-user/xw4aeC68k6Q/vy8Iv0jWCAAJ. Can someone please write this guide? It is clearly tripping up a lot of users on something very simple. cc @ElijahCaine
from docs.
@philips I'm writing and testing a doc now. PR should be up by the end of the day.
from docs.
Related Issues (20)
- CoreOS Cluster with batch slurm managment HOT 2
- CoreOS Cluster with batch slurm managment HOT 1
- os/env: show how to forward global env to docker containers
- 'Customizing the SSH daemon' doc doesn't show how to modify sshd_config params after first boot HOT 2
- Bubble up Breaking Changes into Stable release notes. HOT 3
- Image verification links wrong HOT 2
- Disable Update HOT 8
- Minor Improvement to Using Cork Section HOT 4
- build_package error solution HOT 3
- Title on VirtualBox Page is Misspelled. HOT 1
- coreos_production_hyperv_image.vhd.bz2 how to login HOT 2
- CloudFormation templates have out-of-date image references HOT 2
- Domains to whitelist for updating CoreOS to work
- Migration guide converts string "0644" to raw 0644; should not use octal syntax. HOT 1
- Documentation issue about EBS
- 3 vulnerabilities NFLX-2019-001 HOT 1
- VirtualBox docs result in SSH password prompt
- Is Coreos quay stop developing and migrate to Red Hat? HOT 1
- None human readable config files HOT 1
- Guide for disabling IPv4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.