From 3b4fe91a6a33dfb53d79a93ebdb842ee11c71d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de> Date: Mon, 13 Feb 2023 16:11:06 +0100 Subject: [PATCH] fix: configure udev rule to make zram swap reboot persistent --- tasks/configure_swap.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tasks/configure_swap.yml b/tasks/configure_swap.yml index caebbbf..2862af1 100644 --- a/tasks/configure_swap.yml +++ b/tasks/configure_swap.yml @@ -15,7 +15,6 @@ when: ansible_os_family == "Debian" # RHEL part is based on https://www.techrepublic.com/article/how-to-enable-zram-rocky-linux/ -# Note: all that udev stuff from that guide doesn't work. We'll use CLI commands. # More docu on zram at https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html - name: configure zram based swap (RedHat) block: @@ -41,6 +40,12 @@ create: true line: "options zram num_devices=1" mode: "0644" + - name: configure udev to initialise zram device on bootup + ansible.builtin.lineinfile: + path: "/etc/udev/rules.d/99-zram.rules" + create: true + line: "KERNEL==\"zram0\", ATTR{disksize}=\"{{ ( ansible_facts.memtotal_mb / 2 ) | round | int }}M\",TAG+=\"systemd\"" + mode: "0644" - name: find out if zram Kernel module has been loaded already ansible.builtin.command: "lsmod" register: kernel_modules -- GitLab