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
This commit is contained in:
Jakub Kadlcik 2022-01-23 21:28:16 +01:00
parent 104fb66c9c
commit 415731c1ac

View file

@ -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"