nefelim4ag / systemd-swap

Script for creating hybrid swap space from zram swaps, swap files and swap partitions.
GNU General Public License v3.0
550 stars 81 forks source link

ERRO: swapfc_path is located on an unknown filesystem #211

Open unz3r0 opened 2 years ago

unz3r0 commented 2 years ago

I saw the same problem today. I checked after the whole system freezes. No idea how this happen actually, but here is how I solved it:

OS -> Manjaro Packages -> timeshift timeshift-autosnap grub-btrfs systemd-swap Filesystem -> BTRFS

Problem:

$ sudo systemctl status systemd-swap.service                                                                     
× systemd-swap.service - Manage swap spaces on zram, files and partitions.
     Loaded: loaded (/usr/lib/systemd/system/systemd-swap.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Tue 2022-02-08 21:45:50 CET; 13s ago
    Process: 2662 ExecStart=/usr/bin/systemd-swap start (code=exited, status=1/FAILURE)
   Main PID: 2662 (code=exited, status=1/FAILURE)
     Status: "Monitoring memory status..."
        CPU: 936ms

Feb 08 21:45:49 manjaro systemd[1]: Starting Manage swap spaces on zram, files and partitions....
Feb 08 21:45:49 manjaro systemd-swap[2662]: INFO: Removing working directory...
Feb 08 21:45:49 manjaro systemd-swap[2662]: INFO: Removing files in /var/lib/systemd-swap/swapfc/...
Feb 08 21:45:49 manjaro systemd-swap[2662]: INFO: Writing destroy info...
Feb 08 21:45:49 manjaro systemd-swap[2662]: INFO: swapD: pick up devices from systemd-gpt-auto-generator
Feb 08 21:45:49 manjaro systemd-swap[2662]: INFO: swapD: searching swap devices
Feb 08 21:45:50 manjaro systemd-swap[2662]: ERRO: swapfc_path is located on an unknown filesystem
Feb 08 21:45:50 manjaro systemd[1]: systemd-swap.service: Main process exited, code=exited, status=1/FAILURE
Feb 08 21:45:50 manjaro systemd[1]: systemd-swap.service: Failed with result 'exit-code'.
Feb 08 21:45:50 manjaro systemd[1]: Failed to start Manage swap spaces on zram, files and partitions..
sudo btrfs subvolume list  /
ID 257 gen 142377 top level 5 path @home
ID 310 gen 139209 top level 5 path @swap
ID 824 gen 141132 top level 5 path timeshift-btrfs/snapshots/2021-12-19_22-51-31/@
ID 1244 gen 108447 top level 824 path timeshift-btrfs/snapshots/2021-12-19_22-51-31/@/var/lib/systemd-swap/swapfc
ID 1264 gen 142377 top level 5 path @
ID 1294 gen 142377 top level 5 path timeshift-btrfs/snapshots/2022-02-08_21-43-00/@

Timeshift did a snapshot of the swapfc path and systemd-swap use the backup path somehow...

  1. I needed to delete this subvolume:

    sudo btrfs subvolume delete  /run/timeshift/backup/timeshift-btrfs/snapshots/2021-12-19_22-51-31/@/var/lib/systemd-swap/swapfc
  2. Remove the folder:

    sudo rm -Rf /var/lib/systemd-swap/swapfc
  3. Start again:

    sudo systemctl start systemd-swap.service 
    sudo systemctl status systemd-swap.service  

Now it works again.

$ sudo btrfs subvolume list  /                                                                           ✔ 
ID 257 gen 142402 top level 5 path @home
ID 310 gen 139209 top level 5 path @swap
ID 1264 gen 142402 top level 5 path @
ID 1295 gen 142389 top level 1264 path var/lib/systemd-swap/swapfc

(I deleted also all snapshots, just in case)

I guess systemd-swap has not timeshift in mind:

https://github.com/Nefelim4ag/systemd-swap/blob/6e4fd335714adf34c0d50b5c1ea58af5a60cc2d6/src/systemd-swap.py#L280-L292

Please add some safety checks, so that it chooses the swapfc path on @ and not on timeshift-backup. Thank you :-)

(And TimeShift need to exclude this path somehow. No idea, how this works here. But it seems BTRFS Snapshots have no Filter like in rsync mode.)