Closed sedlund closed 5 years ago
I am not sure whether RAM/2 is “sane”. It really depends on the requirements. But you are right, that it would be a good idea to use such a thing in the example config.
(Though with better code: Why combine grep+sed if sed alone can do the same? Or use awk to get even simpler code and do also the numerics...)
Unfortunately, these possibilities exist only with openrc. With systemd and its sh-is-bad insanity it is probably not so easy.
I use this for coreos
[Unit]
Before=docker.service
ConditionPathExists=!/dev/zram0
[Install]
RequiredBy=docker.service
[Service]
Type=oneshot
ExecStartPre=/usr/bin/sh -c "/usr/bin/systemctl set-environment SIZE=$(( $( free | grep -e "^Mem:" | sed -e 's/^Mem: *//' -e 's/ *.*//') * 3 / 2 ))000"
ExecStart=/usr/sbin/modprobe zram
ExecStart=/usr/sbin/zramctl -f -s $SIZE
ExecStart=/usr/sbin/mkswap /dev/zram0
Consensus of Debian and Ubuntu seems to be half RAM for a sane default.
Pushed
Awesome I will give it a try. Thanks
Ubuntu/Debian etc use a sane default not predetermined number for enabling zram