• OwOarchist@pawb.social
    link
    fedilink
    English
    arrow-up
    17
    ·
    6 小时前

    Yes, swap partitions are shit.

    The real hotness is swap drives.

    Just the use that your old 64GB SSDs were waiting for!

    (Fun fact: in Linux, if you have multiple swap partitions mounted, the kernel will automatically use striping (like RAID) in order to read and write from them as fast as possible. If you have multiple small SSDs used for swap, the read/write speed from swap can actually become pretty fast.)

  • Zenorbi@lemmy.world
    link
    fedilink
    arrow-up
    28
    ·
    9 小时前

    I used to be this guy. We have huge amount of memory in our storage server. Why would we need swap? Well, once the system started killing programs I read up on swap and how the system handles its caches, especially ZFS ARC.

    Short version is that while the system can evict its caches syncronously, it can only async notify ZFS that it should also shrink its caches, but the out-of-memory killer will start killing before ZFS and its kernel counterpart can start to free up memory.

    A tiny bit of swap completely solved this, since swapping is sync for the kernel and the OOM killer will wait for it.

    • Fizz@lemmy.nz
      link
      fedilink
      arrow-up
      5
      ·
      3 小时前

      As well as oom situations, swapping allows the memory to be used more effectively by swapping out anonymous pages that aren’t likely to be used but can’t be dropped.

    • cannedtuna@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      12
      ·
      9 小时前

      Shit did I botch it? I made this on my phone and the toot I copied the script from was just text. Wanted to make it look more interesting so I found this site that let you make the windows. I just went with what I thought looked best.

        • cannedtuna@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 小时前

          It’s based on a common meme template. Yeah it’s tongue in cheek and I guess a lot of commenters can’t tell given this is a memes comm

      • smeg@feddit.uk
        link
        fedilink
        English
        arrow-up
        2
        ·
        8 小时前

        I hope the phone is running PostmarketOS ;)

        TBH I’m sure you could configure a linux terminal to look like that, but yeah it looks very default macos to me

  • 18107@aussie.zone
    link
    fedilink
    English
    arrow-up
    28
    ·
    10 小时前

    No

    15.5/15.5 GB RAM used, plus 16.8/465GB swap

    It turns out the computer mostly freezes once you go past 200% RAM used.

  • 7rokhym@lemmy.ca
    link
    fedilink
    arrow-up
    6
    ·
    7 小时前

    Definitely configure swap, but I don’t think there is much benefit of a swap partition over a swap file these days and swap files are trivial to configure.

  • Jul@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    43
    ·
    11 小时前

    There are good use cases for swap. I work with very performance sensitive memory hogging applications that tend to process in bursts as incoming batched data arrives. We also have a lot of required background “security” applications.

    Having the idle applications move out to swap so that a significant amount of free RAM to allow for the active, real-time applications to expand into is a major boon. RAM is expensive now, so it’s become even more critical to not waste it.

    But even in self-hosting at home I take advantage of it since I have a limited number of servers with limited RAM and a bunch of applications and/or docker containers running, many of which don’t need to be active at all times, but if they were all active, would have trouble with the limited RAM. Swap allows for inactive applications to free up RAM for the active ones and leave enough available at all times to allow an application to quickly spin up new jobs.

    Anyway, sure, for a simple desktop computer without a bunch of junk background applications running for “security” or whatever, and an overabundance of RAM installed, it’s probably not useful. But for high performance, memory hungry applications with lots of background stuff running, it can be a big help.

    That said, there are use cases where the opposite is useful and using a RAM drive is better than writing to disk for cache and temporary logs when you have enough RAM. My opnsense router for instance uses a RAM drive to store cache and logs (logs are mirrored to the NAS for long term storage, so just the local copy is lost on reboot). That system has enough RAM and I’d rather reduce disk wear, and I don’t plan to add too many other applications to that server that it would run low.

    • Kangae_Hishiryo@scribe.disroot.org
      link
      fedilink
      arrow-up
      3
      ·
      5 小时前

      Actually, there are more than these. For example, hibernation and/or hybrid suspension. It’s, AFAIK, mandatory to have a swap partition to be able to hibernate and/or hybrid suspend your device.

    • Supercrunchy@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      10 小时前

      I also found it useful to do some one-off batch processing of a big file without thinking of chunking and doing too complicated things. Imagine something like a 60GB file in a custom format that need to be deduplicated. It’s easier to just load it all up in memory and do run the algorithm 2-3x slower using a 50GB swapfile than spend hours to complicate the algorithm.

      • OwOarchist@pawb.social
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        6 小时前

        Yep. That’s why it can be nice to just have like an old 1TB drive completely used for swap. Things might get slow once it exceeds your physical memory, but at least it will eventually finish successfully – no out of memory crashes here!

      • dan@upvote.au
        link
        fedilink
        arrow-up
        7
        ·
        10 小时前

        I’ve seen so many setups where people encrypt their data but forget to encrypt their swap.

        • DevDave@piefed.social
          link
          fedilink
          English
          arrow-up
          5
          ·
          6 小时前

          what’s the problem? it’s not like you dump the entire contents of your system’s ram to disk any time use hibernate /s

          • dan@upvote.au
            link
            fedilink
            arrow-up
            3
            ·
            6 小时前

            Even without hibernation, data in apps you have open will end up in the swap if your system is ever RAM-constrained.

            • redjard@reddthat.com
              link
              fedilink
              arrow-up
              1
              ·
              3 小时前

              Generally it only happens to programs you keep running in the background and might not use for a long time that also don’t have much background activity. For example password managers.

              • dan@upvote.au
                link
                fedilink
                arrow-up
                1
                ·
                21 分钟前

                It depends on what you set your swappiness to, too. I think Linux distros still have pretty aggressive defaults that swap more than they probably need to.

    • adarza@lemmy.ca
      link
      fedilink
      arrow-up
      2
      ·
      8 小时前

      that’s what trixie’s netinst defaults to when i set up new desktops using encrypted lvm… root and swap volumes inside that, unlocking together at boot. my use doesn’t hit swap much, so it’s nbd. i just leave it like it is. only where an installer doesn’t support encrypted swap partitions do i use a file or ram-based swap instead.

      • dan@upvote.au
        link
        fedilink
        arrow-up
        2
        ·
        7 小时前

        It’s not as bad with LVM since LVM is more flexible. A swap file does still make it easier to change the size as needed though. If you need more swap, you can spin up a new swap file pretty much instantly while the system is running, without having to repartition. You can have both a swap partition and a swap file active at the same time though.

        On systems where the data is encrypted, also encrypting the swap makes sense so I’m glad Debian does that.

      • PervServer@fedinsfw.app
        link
        fedilink
        English
        arrow-up
        7
        ·
        11 小时前

        Nope, I hibernate with a swap file and it’s in a LUKS partition. Although IIRC that whole setup requires me to use systemd boot.

        • redjard@reddthat.com
          link
          fedilink
          arrow-up
          1
          ·
          3 小时前

          I do the same and use ugrd. I think dracut would also work.
          You just set the resume kernel parameter to the decrypted memory device with the swapfile offset.
          As long as the initrd attempts a resume after it decrypted all volumes it’ll work, and the initrd doesn’t even need to understand why and what was resumed from

      • Ooops@feddit.org
        link
        fedilink
        arrow-up
        2
        ·
        8 小时前

        It’s doable with a swap file instead. But some filesystems are more supportive than others.

        For example BTRFS doesn’t support swapfiles over multiple devices (so my raid1c3 spanning 3 differently sized disks for example) and also swapfiles must be completely pre-allocated.

        And no matter the filesystem you need to manually tell the kernel device and physical offset for the file via kernel parameters. Which can again be easier on some than on others (also causing the no-multiple-device filesystem problem mentioned above.

        • redjard@reddthat.com
          link
          fedilink
          arrow-up
          1
          ·
          3 小时前

          btrfs’s handling makes sense. The kernel talks to the disk directly, the file is just a pointer for what range it uses, and a placeholder for the filesystem. Something like raid, balancing, cow, all won’t work because the kernel doesn’t even go through btrfs to change the swap"file".
          If you want a proper file as swapfile, with the corresponding overhead, you can make a regular file and mount it via loopback then use it as a swap device.

        • redjard@reddthat.com
          link
          fedilink
          arrow-up
          1
          ·
          3 小时前

          So you shut your pc down like a caveman when you do hardware upgrades or repairs or move apartments?

          • dan@upvote.au
            link
            fedilink
            arrow-up
            1
            ·
            22 分钟前

            Yeah I shut down every day. It boots up fast enough that it’s really not an issue.

  • rem26_art@fedia.io
    link
    fedilink
    arrow-up
    8
    ·
    9 小时前

    Building a PC in 2026 be like “I cant afford RAM, but I can use a whole TB hard disk I shucked from an old WD external as swap and maybe my PC will feel modern”

  • Blue_Morpho@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    11 小时前

    “Unresizeable block device at end of disk”

    Classically the swap partition was located at the physical middle of the drive so that on average, no matter where the heads where, the swap partition wasn’t far away

    • palordrolap@fedia.io
      link
      fedilink
      arrow-up
      5
      ·
      9 小时前

      I actually did this for a laugh a very, very long time ago. I had upgraded my 75MHz Pentium machine from 8MB to a whopping 40MB, so since I knew it would run fine with just 8, I installed a TSR RAMdisk and told Windows 3.1 to put its swap on that drive.

      It worked great, but I decided I’d rather use the memory for other things.

      But in more modern times, I’ve literally forced browser caches into memory-based tmpfs to take the load off system disks, which is basically the same thing. And it reduces wear on my hardware.

  • provectus@lemmy.ml
    link
    fedilink
    English
    arrow-up
    5
    ·
    9 小时前

    Then what is the setup if my computer only has 4GB of memory for daily driving? Just curious because swap partitions are what I normally do on limited resource machines.

    • mlg@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      8 小时前

      Dunno how well zswap handles at that size, but the point is that is compresses swap into RAM, so it would use a max of 819.2M for a total of 2457.6M of swap space. If you need more, then by all means, use a swap file or partition lol.

      Actually linux easily supports multiple and tiered swap mounts, so you could even go zswap + ssd swap + hdd swap, or a cheapo “burn at your own risk” usb flash swap lol.

    • muhyb@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      6 小时前

      Eh, it’s fine. That’s what I do with 4 GB RAM as well. However even though I set 8 GB swap on that machine I noticed it’s hardly using the half of it at most. (Using Void Linux)

  • 87Six@lemmy.zip
    link
    fedilink
    arrow-up
    15
    ·
    11 小时前

    All I know is that I had 16GB RAM and 4GB swap and I used to get crashes sometimes.

    Set that fucker to 32GB out of spite, now no crashes. No idea why that helped. But I guess I do have like 15 tabs open on the regular (web dev)

    • JasonDJ@lemmy.zip
      link
      fedilink
      English
      arrow-up
      13
      ·
      11 小时前

      15 tabs? Those are rookie numbers. Unless you mean “before 8:07 Monday morning”.

      • tal@lemmy.today
        link
        fedilink
        English
        arrow-up
        8
        ·
        11 小时前

        I don’t recall that, but IIRC it does need to be a minimum of installed RAM if you want to be able to hibernate, since then you write out the contents of your memory to swap. That makes having at least as much swap as RAM a good rule of thumb for many systems.

        IIRC kernel crash dumps also make use of swap in a similar way, though I assume that in most sane scenarios, it’s not going to actually require as much swap as physical memory, because you won’t have all of your physical memory allocated to the kernel.

        On non-exotic Linux systems, I always make sure to have more swap than physical RAM.

        • rumschlumpel@feddit.org
          link
          fedilink
          arrow-up
          1
          ·
          3 小时前

          I don’t recall that, but IIRC it does need to be a minimum of installed RAM if you want to be able to hibernate, since then you write out the contents of your memory to swap.

          IF RAM used + swap used don’t exceed total swap space. Yeah, sometimes I run into that. Usually solved by killing webbrowsers, which suggests that most of the swap space is filled with unused webpages…

    • treadful@lemmy.zip
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 小时前

      But I guess I do have like 15 tabs open on the regular (web dev)

      Minor league shit.

    • zitrone 🍋@europe.pub
      link
      fedilink
      arrow-up
      5
      ·
      8 小时前

      right real linux user do everything in the tty and maybe put something in the framebuffer if they want to view an image or similar

    • cannedtuna@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      8 小时前

      Used a website to make the windows since I was on mobile. Thought it looked too plain w/o the window decorations, but yeah. I mean there’s so many distros and themes, who’s to say it couldn’t be Linux. I’ve seen KDE reskinned to look like OSX

      • alecsargent@lemmy.zip
        link
        fedilink
        arrow-up
        5
        ·
        7 小时前

        It’s fine, I really like MacOS X too. To be fair those window decorations looks real nice as demos.