summaryrefslogtreecommitdiff
path: root/config-mgmt-swap.PKGBUILD
blob: 48f3318f1f29eb05e34d5e7ee2c830582bec11f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
. ${BUILDFILE%/*}/common.sh
pkgver=20170322

package() {
preamble

depends=(systemd-swap)
conflicts=('linux-lts<4.7') # because we want z3fold compression from 4.7

# In addition to what's configured in fstab, we use systemd-swap to
# manage advanced swap devices.  There are 3 things we enable in
# systemd-swap:
#
#  - zswap: compress pages on disk
#  - zram: compress pages in RAM
#  - swapfc: in emergencies, allocate space in the filesystem to swap
#    to
add-file -m755 usr/share/holo/files/10-"$pkgname"/etc/systemd/swap.conf.holoscript <<EOF
#!/bin/sh
sed '
	s/^# Zswap\$/& (compress pages on disk)/
	s/zswap_enabled=.*/zswap_enabled=1/

	/^# ZRam\$/s/.*/& (compress pages in RAM)/
	s/zram_enabled=.*/zram_enabled=1/

	s/swapfc_enabled=.*/swapfc_enabled=1/
' | awk '\$0==""||!x[\$0]++'
EOF

add-unit etc/systemd/system/local-fs.target.wants/systemd-swap.service

postamble
}