Credit to @ryanc@infosec.exchange

I just did the graphic

    • cannedtuna@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      26
      arrow-down
      1
      ·
      21 days ago

      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.

  • Zenorbi@lemmy.world
    link
    fedilink
    arrow-up
    36
    ·
    21 days ago

    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.

    • j3tt@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      21 days ago

      I sometimes cannot do hibernate when I did a scrub on my ZFS. But the first try always frees up the swap and so the second attempts works every time.

  • 87Six@lemmy.zip
    link
    fedilink
    arrow-up
    14
    ·
    21 days ago

    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
      15
      ·
      21 days ago

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

      • tal@lemmy.today
        link
        fedilink
        English
        arrow-up
        8
        ·
        edit-2
        21 days ago

        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.

        • j3tt@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          21 days ago

          I use 1.5-2x the swap on new installations these days. I want hibernate to always work.

          • Klajan@lemmy.zip
            link
            fedilink
            arrow-up
            1
            ·
            21 days ago

            I use the same, but I think to be super conservative It should be 1.5x + VRAM

        • rumschlumpel@feddit.org
          link
          fedilink
          arrow-up
          2
          ·
          edit-2
          21 days ago

          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
      ·
      21 days ago

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

      Minor league shit.

  • Blue_Morpho@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    21 days ago

    “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

    • InnerScientist@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      20 days ago

      Also “unresizeable” as if you can’t just swapoff and just delete and recreated it anywhere (update the path in fstab) and then swapon again.

  • diaphragmwp@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    11
    ·
    edit-2
    20 days ago

    Once tortured myself with having to go through…

    The Android build system. Booo, scary.

    I only wanted a LineageOS boot image built. The recommended specs list 64GiB RAM. Figured wouldn’t apply to me until I tried to build a target literally called “nothing”. It just used up all of the RAM and OOMed about 2 minutes in, building the “build cache” or whatever the fuck it needs to do to “warm up”.

    After a few fucktons of swapspace, turning off some of my daemons, some sysctl fuckery (there were options for limiting process virtual memory size IIRC? I put it all the way up) and taskset -p 0-15:1 (use logical CPUs 0, 2, 4…), I had my laptop allocating 50 something GiB. I have 16GB (decimal) physical RAM installed and I consider that already way too much for my usual needs.

    After about half an hour of the build system build systeming, it just stopped doing that then built the kernel in 4 minutes with everything else in some time too.

    Yes, I have tried just running make directly. That just resulted in an image that did nothing but toggle on and off an empty (no percentage) charging circle via power button.

  • Mwa@thelemmy.club
    link
    fedilink
    English
    arrow-up
    11
    ·
    20 days ago

    SWAP RAM is useful for hibernation mode and fall back ram incase you have low memory.

    • SirLeToet@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      20 days ago

      Also for when you, for whatever reason, run out of physical memory.

      Who here worries torturing their SSDs? Those things will last lifetimes compared to HDD’s of the past (or present).

    • palordrolap@fedia.io
      link
      fedilink
      arrow-up
      7
      ·
      21 days ago

      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.

  • 7rokhym@lemmy.ca
    link
    fedilink
    arrow-up
    9
    ·
    21 days ago

    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.

  • topperharlie@lemmy.world
    link
    fedilink
    arrow-up
    10
    arrow-down
    1
    ·
    21 days ago

    Everyone defending swap like crazy in the comments… so let me give a counter argument specifically for desktop:

    Many years ago I stopped using swap on all my computers (I exclusively use linux) and the reason is: every time anything regarding interactivity went to swap, my system would freeze and literally become unusable for a really long time until I killed something. Since I got tired if that behaviour I decided I prefer for random shit to die but my computer still be usable.

    It wasn’t very often, but I don’t get OOM killer often either (as in I don’t remember the last time it happened and I use linux every day for both work and fun), and the freezing situation was way more annoying, to the point I sometimes ended up cold switching off the computer. I’m surprised on how many people run out of memory constantly. I guess you all are just using linux for servers and have crazy processing of infinite data…

      • topperharlie@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        21 days ago

        yep it was HDD, but with the low amount of times I have any OOM issue, I’m way more worried about NVMe flash burning than a random process being killed once every blue moon.

        In fact I didn’t mention, but since the advent of flash drives what I’ve done is trying to locate heavy disk writing apps and find alternatives for them, amid disabling many logs.

        For swap, it hunts me to think some automatic process I don’t have control over will burn those sweet erase cycles without me noticing just because someone programmed it poorly. I’m way more happy knowing I have some control over it.

    • JamesBoeing737MAX@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      2
      ·
      20 days ago

      Or shotcut. I once ran it on 8GB, minimal arch with no swap. Well.

      And I’m not even trying to build android on my new relatively modern laptop. It won’t work.

  • rem26_art@fedia.io
    link
    fedilink
    arrow-up
    9
    ·
    21 days ago

    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”

  • bdonvr@thelemmy.club
    link
    fedilink
    arrow-up
    8
    ·
    20 days ago

    I basically never used swap until I used some script that was supposed to de-duplicate text messages from SMS backups.

    Turns out feeding it a 100,000 message archive spanning back 15 years will somehow eat up ~80GB of RAM. I doubt it should, I guess it probably just wasn’t optimized for such a large amount.

    So I made a 64GB swap file and it completed fine.

  • provectus@lemmy.ml
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    21 days ago

    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
      6
      ·
      21 days ago

      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.

      • provectus@lemmy.ml
        link
        fedilink
        English
        arrow-up
        3
        ·
        20 days ago

        That is pretty cool. Did not know that. Will still be keeping my partition because it works fine for me.

      • WhyJiffie@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        ·
        19 days ago

        so it would use a max of 819.2M for a total of 2457.6M of swap space.

        calling it total is a bit of a stretch. that’s the best case scenario, when the contents compress well.

        also, zswap might not be a good idea on that system. if it only has 4 GB RAM, it likely has a CPU tht is slower and has only a couple cores, and the modern web is cpu heavy enough as it is

    • muhyb@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      21 days ago

      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)