<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amadeusz Prus on Medium]]></title>
        <description><![CDATA[Stories by Amadeusz Prus on Medium]]></description>
        <link>https://medium.com/@aprus?source=rss-343fa80ec0a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kBGmyriH0ekIoILSNdDAzw.jpeg</url>
            <title>Stories by Amadeusz Prus on Medium</title>
            <link>https://medium.com/@aprus?source=rss-343fa80ec0a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:29:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aprus/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NO-CARRIER, 169.254.x.x, and a NetworkManager Surprise]]></title>
            <link>https://medium.com/@aprus/no-carrier-169-254-x-x-and-a-networkmanager-surprise-5af0b71ee585?source=rss-343fa80ec0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5af0b71ee585</guid>
            <category><![CDATA[no-carrier]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[wayland]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Amadeusz Prus]]></dc:creator>
            <pubDate>Sat, 28 Nov 2026 09:17:41 GMT</pubDate>
            <atom:updated>2026-11-28T09:17:41.965Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pEtXGHrGekwqJtzB.jpg" /></figure><p><strong>TL;DR</strong></p><p>NO-CARRIER in ip a means no physical link — reseat the cable and test it against another port before touching any config. A 169.254.x.x address means DHCP got no answer — and NetworkManager may not retry on its own. sudo nmcli connection up &lt;profile&gt; forces a fresh attempt. On fresh Ubuntu the profile is called netplan-&lt;interface&gt;, not “Wired connection 1”.</p><p>I installed a fresh Ubuntu on a spare machine, with one simple goal: get an SSH server running so I could work on it remotely. Five minutes, tops. Install openssh-server, check the IP, done.</p><p>Except the machine had no network. Plugged in via Ethernet to my access point — nothing. Meanwhile Wi-Fi from the very same access point worked fine on every other device in the house. A fresh install, hardware that was running as my main server the day before, a cable that looked perfectly healthy. Everything <em>should have</em> just worked. It didn’t, and my first instinct was to blame everything at once: the AP, the cable, the fresh install, the universe.</p><p>Here’s how the actual diagnosis went — bottom-up, one layer at a time — and what it taught me about a NetworkManager behavior I somehow never noticed after two decades of Linux use.</p><h3>Layer 1: is there anything in the wire at all?</h3><pre>ip a</pre><pre>2: enp1s0:  mtu 1500 qdisc fq_codel state DOWN</pre><p>NO-CARRIER is the kernel telling you there is no electrical signal on the wire. Full stop. At this point DHCP, netplan, firewall, DNS — none of it matters. There’s nothing to configure a connection <em>on</em>. If you see NO-CARRIER, stay at the physical layer.</p><p>With three suspects — cable, port, NIC — the fastest move is one isolation test that cuts the problem in half: same cable, same computer, different device. I plugged straight into my main router instead of the AP:</p><pre>2: enp1s0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc fq_codel state UP</pre><p>LOWER_UP, state UP — link established. Thirty seconds, and the cable and the NIC are both cleared. So the original plug into the AP simply hadn’t made proper contact. Not a fried port, not a dead switch — after re-plugging everything later, the same port worked fine. The most boring possible culprit: a connector that didn’t click all the way in. It happens more often than anyone admits, which is why “unplug it and plug it back in until it clicks” is a legitimate first-line procedure, not an IT crowd joke.</p><p>But the story didn’t end there — because with a working link, I <em>still</em> had no network.</p><h3>Layer 2: the address of despair</h3><pre>inet 169.254.56.10/16 brd 169.254.255.255 scope link noprefixroute enp1s0</pre><p>If you’ve never met the 169.254.0.0/16 range: that’s APIPA, a link-local address the machine assigns to <em>itself</em> when it asked for an address over DHCP and got silence back. It’s not a real address — it’s a distress signal. No gateway, no DNS, no internet.</p><p>A 169.254 address tells you two things at once:</p><ol><li>The physical link works — otherwise the machine wouldn’t have bothered asking.</li><li>The DHCP conversation never happened.</li></ol><p>Which made no sense. The router I was now plugged into was alive and well, happily serving DHCP to a dozen other devices. Why would it ignore this one?</p><h3>The part nobody tells you: NetworkManager may not retry when you expect it to</h3><p>It doesn’t ignore it. It was never asked.</p><p>The DHCP request had gone out earlier — while the cable was still sitting in the dead connection. NetworkManager sent the query into the void, got nothing, fell back to the link-local address… and stayed there. It did not retry automatically — at least not quickly enough to help me here. When I later moved the cable to a working port, from NetworkManager’s point of view nothing had changed: the connection was “already configured”. Configured with garbage, but configured.</p><p>The fix is one command. First, check what your connection profile is actually called:</p><pre>nmcli connection show</pre><pre>NAME             UUID          TYPE      DEVICE<br>netplan-enp1s0   cac41fbe-...  ethernet  enp1s0</pre><p>Small trap here: on a fresh Ubuntu install the wired profile is named netplan-enp1s0 (it’s generated from netplan), not the “Wired connection 1” that half the tutorials on the internet assume. If nmcli greets you with no such connection profile, that’s why.</p><p>Then force a re-activation, which includes a fresh DHCP request:</p><pre>sudo nmcli connection up netplan-enp1s0</pre><pre>Connection successfully activated</pre><p>Two seconds later ip a showed a proper address from the router’s pool, and the machine was on the network. A reboot would have “fixed” it too — but one command is faster, and more importantly, now I know <em>why</em> it worked.</p><h3>The method, distilled</h3><p>Bottom-up, stop at the first layer that fails:</p><ol><li>ip a — LOWER_UP or NO-CARRIER? On NO-CARRIER: reseat the cable, then run the isolation test (same cable + same machine into a different device).</li><li>Got a 169.254.x.x address? DHCP got no answer, and it won’t be retried automatically. sudo nmcli connection up &lt;profile-name&gt; — check the name with nmcli connection show first.</li><li>ip route — the default gateway should point at your router.</li><li>ping — the gateway first, then 8.8.8.8, then a domain name. Three pings that cleanly separate a local problem from a routing problem from a DNS problem.</li></ol><p>Every step is one command with an unambiguous answer. The whole thing — from “dead network” to a working SSH session — took about fifteen minutes, most of which was me carrying a cable between rooms.</p><p>And yes, the SSH server took the promised five minutes after that. The network took the other fifteen. Classic.</p><p>Originally posted at <a href="https://aprus.dev/post/no-carrier-169-254-x-x-and-a-networkmanager-surprise">aprus.dev</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5af0b71ee585" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leaving Xorg fixed everything I’d blamed on NVIDIA]]></title>
            <link>https://medium.com/@aprus/leaving-xorg-fixed-everything-id-blamed-on-nvidia-b30c9106d1e4?source=rss-343fa80ec0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b30c9106d1e4</guid>
            <category><![CDATA[power-management]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[wayland]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[nvidia]]></category>
            <dc:creator><![CDATA[Amadeusz Prus]]></dc:creator>
            <pubDate>Fri, 29 May 2026 12:26:25 GMT</pubDate>
            <atom:updated>2026-05-29T12:27:01.982Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qF5GL9VZOQDvvyxbaKkKBQ.png" /><figcaption>Generated by Gemini</figcaption></figure><p><strong>TL;DR</strong></p><p>Wayland + prime-select on-demand ended the HDMI freezes — the actual problem, and a clean fix. NVIDIA’s Fine-Grained Power Management flag does nothing on a Pascal mobile GPU (I tested it both ways), and the dGPU can’t runtime-suspend on hardware this old. Heat and battery came back anyway — not from the flag, but from finally leaving Xorg.</p><p>Maybe you read my last post about <a href="https://aprus.dev/post/how-to-stop-your-ubuntu-laptop-from-freezing-after-it-eats-your-whole-ram">How to stop your Ubuntu laptop from freezing after it eats your whole RAM</a>. I mentioned there that the NVIDIA GeForce GTX 1050 Ti was worth its own article, so here we are. Just to remind you: I’m using a Dell G3 3579 laptop, bought 8 years ago. Old, but good enough once I got rid of its problems.</p><p>For as long as I can remember, I’ve had a lot of problems with NVIDIA Optimus, starting back with my netbook (do you remember those?), an Asus 1215N. It never worked on Linux as well as it did on Windows. Configuring it and making it at least usable took me hours and was always a trip through hell. I was never fully satisfied.</p><p>After buying the Dell G3 I disabled the NVIDIA GPU in the BIOS. I worked that way for about a year, then I wanted to use an external screen and my problems came back. The Dell’s HDMI port only worked with the NVIDIA card enabled, so I had to turn it back on in the BIOS. Shortly afterwards the computer started getting loud, and the heat killed the battery capacity. My laptop became a desktop PC, permanently connected to AC. I knew it was the NVIDIA GPU’s fault. I tried a lot of potential solutions: upgrading drivers, using unofficial drivers, the Bumblebee project, managing the NVIDIA GPU with Primus, aggressive power management. They all promised a lot, but I never got fully satisfied.</p><p>To help myself and my computer, every 3 months I cleaned it inside and changed the thermal paste and pads. Btw, this is quite a good practice — but to be honest, I’d never have done it at these intervals without those problems.</p><p>A few years later I decided to bring my laptop’s primary function back to life, so I replaced the battery. Unfortunately, after about a year the heat killed the capacity again. I started seriously thinking about buying a new machine.</p><p>A few months ago I started digging one more time, looking for an easy solution to a completely different problem: plugging in HDMI, unplugging it, or suspending the computer took the machine a long time before it showed anything besides a mouse cursor on a black screen. It also hung very often during this procedure. Luckily, I found out the solution was right here, ready to use.</p><h3>What was in the logs?</h3><p>Checking journalctl:</p><pre># last event per boot<br>boot -1 ended: (NO CLEAN SHUTDOWN MARKER — likely hard reset)<br>boot -2 ended: (NO CLEAN SHUTDOWN MARKER — likely hard reset)<br>boot -3 ended: (NO CLEAN SHUTDOWN MARKER — likely hard reset)<br>boot -4 ended: (NO CLEAN SHUTDOWN MARKER — likely hard reset)<br>boot -5 ended: (NO CLEAN SHUTDOWN MARKER — likely hard reset)<br>boot -6 ended: (NO CLEAN SHUTDOWN MARKER — likely hard reset)</pre><p>The last 6 boots all ended with a hard reset… this shows the scale of the problem.</p><p>Let’s check Xorg.log (yes, I was still using Xorg):</p><pre>[129515.894] NVIDIA(GPU-0): LG Electronics LG ULTRAWIDE: connected<br>[129515.938] NVIDIA(GPU-0): LG Electronics LG ULTRAWIDE: connected  ← 44ms later<br>[129516.412] NVIDIA(GPU-0): LG Electronics LG ULTRAWIDE: connected  ← 474ms<br>[129516.455] NVIDIA(GPU-0): LG Electronics LG ULTRAWIDE: connected<br>[129520.246] NVIDIA(GPU-0): LG Electronics LG ULTRAWIDE: connected<br> …and 10 more in 5 seconds</pre><p>A storm of hotplug events. The NVIDIA Xorg driver receives 15 identical events in 5 seconds, and for each one it reconfigured the display. Somewhere in that crowd it appears to hit a race condition with the PRIME bridge, which is what hung the whole rendering pipeline.</p><h3>First step to heaven — Wayland and on-demand</h3><p>One command:</p><pre>sudo prime-select on-demand</pre><p>Now log out, click the cog icon on Ubuntu’s login screen and choose Wayland.</p><p>That’s it. I expected HDMI to stop working, but nothing of the sort happened. Unplug it, plug it back in, and it comes up faster than a blink — I’m in heaven. Problem solved.</p><h4>Why that fixed it</h4><p>The freezes were never really about HDMI. They were about which GPU was in charge — and on X11 I didn’t get to choose.</p><p>The HDMI port on this laptop is wired to the NVIDIA chip, not the Intel one. Under Xorg, the only way to make it work was to run the NVIDIA driver as the primary PRIME provider. The moment I tried an Intel-only setup with the NVIDIA driver out of the way, HDMI stopped working properly. So prime-select nvidia was never a preference — it was the price of having an external screen at all.</p><p>And that mode is exactly what broke. With NVIDIA primary it renders everything, including the desktop on the laptop’s own panel, and the display side runs through the X.Org NVIDIA driver — decades-old X11 code. The built-in screen is wired to Intel, so even the internal display was routed dGPU → PRIME → Intel scanout. Every HDMI hotplug landed in that NVIDIA X driver, which tried to reconfigure the whole layout for each of the fifteen connect events, and somewhere in that pile it hit the race the logs pointed to and rendering hung.</p><pre>before · X11, NVIDIA primary:     HDMI hotplug → NVIDIA DDX → reconfig per event → hang<br>after  · Wayland, Intel primary:  HDMI hotplug → kernel DRM event → mutter handles it</pre><p>prime-select on-demand plus Wayland breaks the bind. The Intel iGPU becomes the primary, display-driving GPU, and the NVIDIA card drops to offload — powered up only when something needs it, including lighting up that HDMI-attached output. Mutter, GNOME&#39;s Wayland compositor, does its own mode-setting and hotplug handling straight through the kernel&#39;s DRM/KMS, with no X.Org server and no NVIDIA DDX in the path. I get the external screen without making NVIDIA primary — the thing X11 never let me do. A monitor going in or out is now just a kernel DRM event the compositor absorbs. No legacy X driver to choke on it, no PRIME bridge to race.</p><h4>What about power consumption?</h4><p>Well, not good. Turning my computer back into a laptop would probably frustrate me more than just accepting the current state. New battery, about an hour and a half of work off AC. Not terrible, but I expected more. Let’s see. I ran this command:</p><pre>nvidia-smi -q -d POWER,PERFORMANCE,CLOCK,TEMPERATURE</pre><p>The interesting part is here:</p><pre>Performance State                                  : P8<br>    ...<br>    Module Power Readings<br>        Average Power Draw                             : N/A<br>        Instantaneous Power Draw                       : N/A<br>        Current Power Limit                            : N/A<br>        Requested Power Limit                          : N/A<br>        Default Power Limit                            : N/A<br>        Min Power Limit                                : N/A<br>        Max Power Limit                                : N/A</pre><p>And the next command shows the current power consumption:</p><pre>upower -i $(upower -e | grep BAT)</pre><p>And the part we care about:</p><pre>energy-rate:         33,3288 W</pre><p>Clearly, the power consumption is too high for a laptop at idle.</p><h4>What are P-states and D-states?</h4><p>P-states (P0–P8) describe how hard the GPU works while it’s awake — P8 is the deepest idle, clocks gated down, but the silicon still powered. D-states are a separate axis: they describe whether the card is on the PCIe bus at all. D0 is fully online. D3cold means the device is effectively powered off — about as close to zero watts as the hardware gets. What I want is D3cold. What I’m stuck with is D0 + P8: idle in the only way the driver knows how, but never actually off.</p><h3>Second step — let the driver suspend the GPU itself</h3><p>So I want the card deeper than P8. I was debugging this with an AI assistant (Claude, as it happens), and it told me about Fine-Grained Dynamic Power Management — NVIDIA’s feature for runtime-suspending the GPU when nothing is using it — and that my GP107M was on a “limited support” list for it. The driver README ships right there in /usr/share/doc/nvidia-driver-580/, so the claim was at least checkable, and it sounded plausible enough. It&#39;s only a module flag — set it explicitly, reboot, and see what happens. Worth a try.</p><p>It’s one module option, one file:</p><pre># /etc/modprobe.d/nvidia-power-management.conf<br>  options nvidia &quot;NVreg_DynamicPowerManagement=0x02&quot;</pre><p>Then rebuild the initramfs (NVIDIA loads early, so the option has to be there from the start) and reboot:</p><pre>sudo update-initramfs -u<br>sudo reboot</pre><p>After the reboot, the param had stuck:</p><pre>cat /proc/driver/nvidia/params | grep DynamicPower<br>  DynamicPowerManagement: 2<br>  DynamicPowerManagementVideoMemoryThreshold: 200</pre><p>The driver took the option. So I checked the draw again:</p><pre>upower -i $(upower -e | grep BAT) | grep energy-rate</pre><p>Result:</p><pre>energy-rate:         14,9264 W</pre><p>From 33 W down to 15. I’d cut idle power by more than half with one flag and a reboot — on a chip the README said wouldn’t support it. I closed the laptop feeling clever.</p><p>I was wrong about why.</p><h3>Third step — the wall, and what’s on the other side of it</h3><p>Here’s the first crack: the dGPU was still sitting in D0. If the flag had really enabled runtime suspend, the card should have spent at least some time asleep. I can check directly — every PCI device in /sys reports its current power state and how long it has spent in each:</p><pre>for d in /sys/bus/pci/devices/*; do<br>  [ &quot;$(cat $d/vendor 2&gt;/dev/null)&quot; = &quot;0x10de&quot; ] || continue<br>  bdf=$(basename $d)<br>  echo &quot;=== $bdf ===&quot;<br>  echo &quot;runtime_status: $(cat $d/power/runtime_status)&quot;<br>  echo &quot;power_state:    $(cat $d/power_state)&quot;<br>  echo &quot;active_time:    $(cat $d/power/runtime_active_time) ms&quot;<br>  echo &quot;suspended_time: $(cat $d/power/runtime_suspended_time) ms&quot;<br>done</pre><p>Output, after 28 hours of uptime:</p><pre>=== 0000:01:00.0 ===     ← the GPU itself<br>runtime_status: active<br>power_state:    D0<br>active_time:    102395816 ms<br>suspended_time: 0 ms<br><br>=== 0000:01:00.1 ===     ← HDMI audio on the same chip<br>runtime_status: suspended<br>power_state:    D3hot<br>active_time:    24123 ms<br>suspended_time: 102371729 ms</pre><h4>Same chip, opposite outcome</h4><p>Read that twice. The audio function and the GPU sit on the <strong>same physical chip</strong>, share the <strong>same driver</strong>, the <strong>same DPM setting</strong>, the <strong>same </strong><strong>power/control: auto</strong>. The audio function has been asleep for 28 hours straight, woken up for 24 seconds total. The GPU itself, in those same 28 hours, has not been suspended for a single millisecond. Zero.</p><p>At first I blamed userspace. There are obvious suspects holding the card busy:</p><pre>sudo lsof /dev/nvidia* | awk &#39;NR==1 || /nvidia[0-9]|nvidiactl|nvidia-modeset/&#39;</pre><p>There they are — gnome-shell, Xwayland, brave, all keeping /dev/nvidia-modeset open permanently under Wayland. On hardware that supports runtime suspend, a single open handle is enough to block it, so this looked like the answer. There&#39;s even an irony to it: Wayland is the same thing that rescued me in step one, which would make the fix for the freezes the very thing keeping the card awake.</p><p>Tidy theory. It has a hole. The audio function shares the chip and the driver and still reaches D3hot, so something on this package can suspend past held handles. And the flag that supposedly turned all of this on does nothing — which I only worked out by reading the README myself instead of trusting what I&#39;d been told.</p><p>Fine-Grained DPM, and NVIDIA runtime suspend in general, needs Turing or newer on a Coffee Lake or newer chipset. Pascal isn’t on the list — not the “limited support” the assistant had promised, not on it at all. On a pre-Ampere chip the driver accepts NVreg_DynamicPowerManagement and then ignores it. The 2 in params means the string parsed, nothing more.</p><p>So I tested the one thing that settles it: removed the flag, rebooted, and measured idle on battery under the same conditions, with it and without it.</p><pre># with the flag    → ~13 W idle, GPU in D0, suspended_time 0<br># without the flag → ~14 W idle, GPU in D0, suspended_time 0</pre><p>Identical. The flag changes nothing. Which means the drop I was so pleased about came from the reboot, not the option — I’d changed two things at once and credited the wrong one. The card was never going to suspend either way.</p><p>I still tried to force it. I wrote a udev rule that, on AC unplug, would drop autosuspend_delay_ms to 100 ms and shove the card down fast. Except reading that file in /sys/bus/pci/devices/0000:01:00.0/power/ just returns Input/output error — and strace shows the open succeeds while the read fails, which pins it to the attribute&#39;s own show callback. That turned out to be the kernel being precise, not broken: autosuspend_delay_ms only returns a value once a driver has actually enabled autosuspend on the device, and returns EIO until it does. Runtime PM here is even set to auto and enabled — but the NVIDIA driver never switches autosuspend on, so there&#39;s no delay to read, let alone tune. Same wall as the flag, one layer down: a dial for a mechanism this GPU doesn&#39;t run. The rule was dead before it ran.</p><blockquote><strong><em>It was never a config I was missing. It’s a GPU generation I don’t have.</em></strong></blockquote><p>The held handles aren’t the wall. They’d matter on a card that can do runtime D3 — this one can’t. D3cold (which would also need full ACPI cooperation) isn&#39;t one flag away — it&#39;s one silicon generation away. RTD3 was never built for GP107M, so the card stays in P8 idle and never goes dark, whatever I set.</p><p>I deleted the udev rule. It was elegant and completely useless on this hardware.</p><p>So where does that leave the laptop? The dGPU never fully powers off — it can’t, not on Pascal — but I stopped caring, because that was never the thing making the machine unusable. The freezes were: six hard resets in six boots, every resume a gamble. Those are gone — resume, suspend, HDMI in and out, all clean. And the thread running under all of it — the freezes, the dGPU-as-primary layout, the heat — was the old X11 + NVIDIA setup. Xorg was the villain the whole time. Leaving it for Wayland fixed the problem I actually had.</p><h3>A subjective note</h3><p>I never logged temperatures or battery life carefully back when things were bad, so take this part as impression, not measurement. But the difference in daily use isn’t subtle.</p><p>The laptop used to run hot enough to feel through the chassis, with the fans pinned. And on a G3 the fans don’t pin discreetly — this machine is notorious for them spinning up hard and late, as the GPU climbs toward the upper end of its range. A healthy GTX 1050 Ti idles around 40 °C. The chip is rated to run into the 80s and only throttles up near the mid-90s. Mine was loud, so it was living somewhere up there. Now the dGPU sits at ~42 °C and the fans are barely audible.</p><p>Battery off AC went from about an hour and a half to close to four. None of that came from the power-management flag I burned an evening on — it came from getting off Xorg. That’s the whole lesson, really: I spent the effort chasing a config knob, and the actual fix was abandoning a stack I should have left years ago.</p><p>Originally posted at <a href="https://aprus.dev/post/leaving-xorg-fixed-everything-i-d-blamed-on-nvidia">aprus.dev</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b30c9106d1e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to stop your Ubuntu laptop from freezing after it eats your whole RAM]]></title>
            <link>https://medium.com/@aprus/how-to-stop-your-ubuntu-laptop-from-freezing-after-it-eats-your-whole-ram-6959622c9b41?source=rss-343fa80ec0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6959622c9b41</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Amadeusz Prus]]></dc:creator>
            <pubDate>Thu, 14 May 2026 10:28:00 GMT</pubDate>
            <atom:updated>2026-05-28T13:06:23.734Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCwerzQSTVhiU9Nz2QTtYA.png" /><figcaption>Generated by Gemini</figcaption></figure><p><strong>tl;dr:</strong> run the bash script at the bottom.</p><p>I’m a software developer who has been using Ubuntu on his laptop for 20+ years now. I run heavy RAM-consuming tools — Docker, IDEs, 50+ browser tabs, multiple Claude agents working in parallel, etc. The machine is fairly old, but still good enough that I don’t want to buy a new one.</p><p>One of my major problems was <em>“sometimes, under pressure, it just freezes.”</em> The only solution was a hard reset, which killed my current flow and desktop state. I looked into it a few years ago and ended up upgrading my RAM from 16 GB to 32 GB. That didn’t solve the issue, but it limited the freezes to an acceptable number.</p><p>Now, after a few years, the freezes came back — so my frustration forced me, once again, to find a real fix. My coworkers keep telling me to <em>buy a Mac, because it just works</em> (which is not true 😄). I have to admit, I considered it carefully. I almost purchased one. Fortunately, the voice in my head said:</p><blockquote><em>Why? It works. It just freezes sometimes.</em></blockquote><p>And I found the solution.</p><p>My machine is a <strong>Dell G3 3579</strong> — i7–8750H, 32 GB RAM, Nvidia GeForce GTX 1050 Ti (which has its own problems, probably worth another article 😸), Ubuntu 24.04.</p><h3>First layer: systemd-oomd</h3><p>It monitors PSI (Pressure Stall Information). When memory pressure grows <strong>above</strong> a threshold, it kills the most resource-consuming process <em>before</em> the system freezes.</p><h3>Second layer: zram</h3><p>It creates a swap device inside your RAM and stores compressed data there. It’s faster than regular disk swap, and thanks to compression, it lets you fit more data into your RAM than you otherwise could.</p><h3>Third layer: sysctl tuning</h3><p>Normally vm.swappiness=60 is calibrated for disk swap. For zram you want vm.swappiness=180 to make compression more aggressive, and vm.page-cluster=0 because read-ahead is useless when the swap already lives in RAM.</p><h3>Heads-up</h3><p>In Ubuntu 24.04 the zram-tools package leaves everything commented out in /etc/default/zramswap, which falls back to a hardcoded:</p><pre>SIZE=256        # MB — useless for a 32 GB machine<br>ALGO=lz4        # faster, but worse compression than zstd</pre><p>The script below fixes that as part of step 2.</p><h3>The script</h3><p>Save it as setup-memory.sh and run sudo bash setup-memory.sh. It&#39;s idempotent — safe to re-run.</p><pre>#!/bin/bash<br># Aggressive memory management for Ubuntu 24.04 desktop with 32GB RAM.<br># Installs systemd-oomd (proactive OOM killer) + zram swap (compressed RAM<br># swap, 50% RAM, zstd) and tunes vm sysctls for zram-friendly behavior.<br><br>set -e<br><br>echo &quot;=== 1/4 install systemd-oomd + zram-tools ===&quot;<br>apt update<br>apt install -y systemd-oomd zram-tools<br><br>echo<br>echo &quot;=== 2/4 configure zramswap (50% RAM, zstd) ===&quot;<br># Backup current config<br>cp /etc/default/zramswap /etc/default/zramswap.bak.$(date +%s) 2&gt;/dev/null || true<br><br># Override the broken defaults<br>sed -i &#39;s/^#\?ALGO=.*/ALGO=zstd/&#39; /etc/default/zramswap<br>sed -i &#39;s/^#\?PERCENT=.*/PERCENT=50/&#39; /etc/default/zramswap<br><br>echo &quot;Current /etc/default/zramswap:&quot;<br>grep -E &quot;^[^#]&quot; /etc/default/zramswap<br><br>echo<br>echo &quot;=== 3/4 enable services (start + run on boot) ===&quot;<br>systemctl enable --now systemd-oomd<br>systemctl enable --now zramswap<br>systemctl restart zramswap<br><br>echo<br>echo &quot;=== 4/4 sysctl tuning ===&quot;<br>cat &gt; /etc/sysctl.d/99-zram-tuning.conf &lt;&lt;&#39;EOF&#39;<br>vm.swappiness=180<br>vm.page-cluster=0<br>vm.watermark_boost_factor=0<br>vm.watermark_scale_factor=125<br>EOF<br>sysctl --system<br><br>echo<br>echo &quot;=== verify ===&quot;<br>sleep 1<br><br>echo &quot;--- services ---&quot;<br>for s in systemd-oomd zramswap; do<br>  printf &quot;  %-15s  active=%-8s enabled=%s\n&quot; \<br>    &quot;$s&quot; \<br>    &quot;$(systemctl is-active $s)&quot; \<br>    &quot;$(systemctl is-enabled $s)&quot;<br>done<br><br>echo<br>echo &quot;--- zram device ---&quot;<br>swapon --show<br>for z in /sys/block/zram*; do<br>  [ -d &quot;$z&quot; ] || continue<br>  name=$(basename &quot;$z&quot;)<br>  algo=$(cat &quot;$z/comp_algorithm&quot; 2&gt;/dev/null | grep -oE &#39;\[[^]]+\]&#39;)<br>  size=$(numfmt --to=iec --suffix=B &lt; &quot;$z/disksize&quot; 2&gt;/dev/null)<br>  echo &quot;  $name: size=$size, algo=$algo&quot;<br>done<br><br>echo<br>echo &quot;--- free -h ---&quot;<br>free -h<br><br>echo<br>echo &quot;--- sysctl ---&quot;<br>sysctl vm.swappiness vm.page-cluster vm.watermark_boost_factor vm.watermark_scale_factor<br><br>echo<br>echo &quot;=== ready ===&quot;</pre><p>Enjoy your new laptop experience!</p><p>Originally published at <a href="https://aprus.dev/post/how-to-stop-your-ubuntu-laptop-from-freezing-after-it-eats-your-whole-ram">aprus.dev</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6959622c9b41" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>