Linux
Welcome to c/linux!
Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!
Rules:
-
Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.
-
Be respectful: Treat fellow community members with respect and courtesy.
-
Quality over quantity: Share informative and thought-provoking content.
-
No spam or self-promotion: Avoid excessive self-promotion or spamming.
-
No NSFW adult content
-
Follow general lemmy guidelines.
view the rest of the comments
In the sysstat package, there's a command,
iostat
, that shows the amount of time that the average CPU (core) is waiting for something."User" is the CPU time used by regular processes. "Nice" is the time used by "niced" processes, stuff running at low priority. "System" is time used by the kernel. "Iowait" is the time waiting for I/O operations to complete.
If you're bounded on I/O, then the iowait number is probably going to be relatively high.
It'll also show you I/O load on each device (and the sysstat package can log this over time, let you use
sar
to see historical numbers).You can artificially induce load on a given I/O device to see whether load on it induces your problem. Something like this:
That'll start your system just writing zeroes to a file. If it's I/O contention on the mSATA drive, then I'd expect you to see the problems you mentioned.
One thing you might check is whether your system is logging errors during this time. I don't know what a failing SSD looks like, but in my experience a failing rotational drive would often see errors and then attempts to re-perform I/O operations. That produces seriously-degraded disk I/O performance. These errors will show up in the kernel log. To see kernel errors since the current boot:
The smartmontools package contains a command,
smartctl
, which will let you see what your drive thinks of its own health. I'm not really familiar with what a failing SSD would look like, but with rotational drives, it can indicate that something's wrong with the drive, and it looks like my SSDs do report SMART status.Moving swap
Linux can, if it needs to, use a swap file instead of a swap partition, so you don't need to repartition your NVMe if you just want to try putting your swap on the NVMe.
If you want to, first, for the current boot, disable all the active swap partitions.
If you run
top
, you'll see the available swap be at zero.Then you want to create the swap file. Say we drop it in /var:
And then you can enable it:
Then see how things perform.
If it makes your problem go away and you want to make the change persistent:
In /etc/fstab, you'll have a line for your swap partition that the system reads at each boot. Will probably look something like this:
Comment that out by sticking a "#" at the beginning of your line, and put a line in for your new swapfile on the NVMe:
Thanks for the very detailed guide. Would you advice to have such a large swapfile? If I remember correctly, the old advice was to have double the storage in swap than in RAM. But after 4 or 8GB of RAM or so, this is no longer needed and just a generic amount of swap is kinda needed.
I'm moving now my swapfile to the nvme. I might put it in /var indeed. Thanks!
On laptops, you normally want at least as much swap space as you do physical memory, as when you hibernate the thing, that's where the hibernation data is stored, and if you don't have enough space there, hibernation will fail. IIRC, it's also required for some kernel debugging technique (where, as hazy memory indicates, I believe the kernel can basically "dump core" to swap space, then reboot and write it out to regular storage). So it certainly works, because there are a lot of Linux systems out there that use that much relative to physical memory. Though I admit that I've never tried using a swap file instead of a swap partition, myself.
It's not quite like the old days, with rotational drives, and pre-OOM killer, where having a huge amount of swap would let the system bog down to the point where it couldn't be used.
Do you need 32GB swap? Probably not, if you don't plan to hibernate the system. But unless you need the storage for something else, probably doesn't hurt. And if you've got a 1TB system drive, I doubt that you're short on space.
I have 128GB of main memory and 128GB of swap on this system. Same 1:1 ratio, and I normally use that on Linux systems.
For the example, I just chose an arbitrary, "reasonable" size. Feel free to pick a size that you feel is better, if you'd prefer something else.