To be clear, I don’t blame the poster of this comment at all for the content of their post – this is accepted as “common knowledge” by a lot of Linux sysadmins and is probably one of the most likely things that you will hear from one if you ask them to talk about swap. It is unfortunately also, however, a misunderstanding of the purpose and use of swap, especially on modern systems.

  • recursive_recursion [they/them]@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    2 years ago

    definitely agreed on against using swap as memory as much as you can especially since it can needlessly wear out your ssd (m.2 on most if not all on modern systems)

    allocating swap is still necessary as it provides features such as:

    • mitigating OOM scenarios (but doesn’t prevent them completely)
    • enabling system hibernation(suspend-to-disk)

    On my journey to learning Arch Linux I’ve personally tried:

    • 0 swap: which was pretty awful with constant unexpected system freezes/crashes
    • swap file: finicky but doable
    • swap partition: typical default/ol’reliable

    the last two doesn’t guarantee 0 problems as user errors such as allocating too much system memory to VMs can cause issues for the host system, but it does tend to mitigate the majority of issues that prevent the perception of system stability in comparison to Windows or Macs

    Resources:

    • DefederateLemmyMl@feddit.nl
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 years ago

      0 swap: which was pretty awful with constant unexpected system freezes/crashes

      I’ve run Arch without swap for many years without issues. The key of course is that you need enough RAM for what you are trying to do with your computer.

      There’s no reason why a 32GB RAM + 0GB swap system should have more problems than a 16GB RAM + 16GB swap system with the same workload. If anything, the former is going to run much better.

      swap file: finicky but doable

      What is finicky about a swap file?

      It’s just this:

      mkswap -U clear --size 4G --file /swapfile
      swapon /swapfile
      

      Done

      If anything it’s way easier to create a file in your filesystem than having to (re-)partition your drive to have a swap partition. Much more flexible too if you want to change your swap configuration in the future.