From 415731c1acabf5121eb757f8825262b3a54c48fb Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Sun, 23 Jan 2022 21:28:16 +0100 Subject: [PATCH] swap: try to make swapfile working on btrfs Since F35, the swap service started failing with: kernel: BTRFS warning (device nvme0n1p5): swapfile must not be copy-on-write swapon[2976986]: swapon: /swap: swapon failed: Invalid argument swap.swap: Swap process exited, code=exited, status=255/EXCEPTION --- tasks/swap.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tasks/swap.yml b/tasks/swap.yml index 3297eedaa0..a94a8fd141 100644 --- a/tasks/swap.yml +++ b/tasks/swap.yml @@ -2,6 +2,15 @@ # swap_file_size_mb # swap_file_path +- name: Touch an empty file that we will use for swap + file: + path: "{{ swap_file_path }}" + state: touch + +- name: On BTRFS we need NoCOW + file: path="{{ swap_file_path }}" + attr: +C + - name: Create swap file command: cmd: "dd if=/dev/zero of={{ swap_file_path }} bs=1024 count={{ swap_file_size_mb }}k"