12.07.2020 00:18, Chris Murphy пишет: > On Sat, Jul 11, 2020 at 12:44 PM Ken D'Ambrosio <ken@xxxxxxxx> wrote: > >> * Swap files. At least last time I checked, it was a PITA to take a >> snapshot of a volume that had a swapfile on it -- I wound up writing a >> wrapper that goes, does a swapoff, removes the file, creates the >> snapshot, and then re-creates the file. Is this still "a thing"? Or >> is there a way to work around that that isn't kludgey? > > Put the swapfile in its own subvolume and don't snapshot it. One way > is to create a (nested) subvolume named "swap" inside of the "root" > subvolume created at installation time; use chattr +C on it; now > create the swapfile per 'man 5 btrfs'. > > Since btrfs snapshots aren't recursive, making a snapshot of 'root' > will not cause a snapshot to be taken of 'swap' or its swapfiles. > swap file requires calculation of absolute disk offset (that is what kernel works with) and this is not supported on btrfs with by systemd: https://github.com/systemd/systemd/blob/d67b1d18fcda2c8c5aacfc50f9591c8dc7a4a8a1/src/shared/sleep-config.c#L240 I believe with current systemd if you manually compute and provide resume=btrfs-partition and resume_offset=absolute-offset-of-swapfile it should take it, but using resume=file-on-btrfs will fail.
