‹ BackHN Continuity

Thread

Swap, ZRAM, Zswap and Hibernate on NixOS

78 points · 27 comments · speckx

  1. gucci-on-fleek · · focus · HN ↗
    I agree with everything else here, but swap files on btrfs should probably be avoided whenever possible [0].

    [0]: <a href="https:&#x2F;&#x2F;btrfs.readthedocs.io&#x2F;en&#x2F;latest&#x2F;Swapfile.html" rel="nofollow">https:&#x2F;&#x2F;btrfs.readthedocs.io&#x2F;en&#x2F;latest&#x2F;Swapfile.html

    1. ciferkey · · focus · HN ↗
      Right, you are good to do swap files on btrfs since linux 5.0 or so as long as you follow some rules. Disko thankfully covers all those details for you, but I shouldn&#x27;t have skipped over that in the piece. I&#x27;ll make an update when I get a chance.
      1. gucci-on-fleek · · focus · HN ↗
        Swap files work, but I wouldn&#x27;t quite say &quot;you are good to do swap files on btrfs&quot; because the official documentation (the page I linked earlier) says

        &gt; filesystem - must be only single device

        &gt; This means swapfiles will have an amplified impact, much larger than the size of the swapfile itself.

        &gt; Users should be aware of the impact when using swapfiles alongside other data. This is especially discouraged for root filesystem.

        If a swap file is the only thing that will work with your setup, then it&#x27;s fine to use one, but if you&#x27;re at all able to use a swap partition, then that&#x27;s a far better choice. (Swap files are fine on ext4 and xfs; it&#x27;s only COW filesystems like btrfs and zfs where they should be avoided.)

        1. jasomill · · focus · HN ↗
          While everything else is pretty obvious from the nature of an unmovable file, &quot;scrub will skip those block groups which have extents of an active swapfile on them, and those block groups may also contain extents belonging to other files&quot;.

          Then again, I mostly use XFS, which has no data checksums at all, so YMMV.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.