[systemd-devel] systemd-way for initialization zram swap

Oleksii Shevchuk alxchk at gmail.com
Mon Nov 19 12:16:27 PST 2012


That's enough for me:

# cat /etc/udev/rules.d/01-zram.rules 
KERNEL=="zram[0-9]", ENV{SYSTEMD_WANTS}="zram-swap at zram%n.service", TAG+="systemd"

# cat /etc/systemd/system/zram-swap\@.service 
[Unit]
Description=Setup swap on zram based device %i
BindsTo=dev-%i.swap
After=dev-%i.device
Requires=dev-%i.device
Before=dev-%i.swap
Wants=dev-%i.swap

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/conf.d/%i-size
ExecStart=-/bin/sh -c 'echo $SIZE > /sys/class/block/%i/disksize'
ExecStart=-/sbin/mkswap /dev/%i
ExecStop=-/bin/sh -c 'echo 1 > /sys/class/block/%i/reset'



More information about the systemd-devel mailing list