NVMe scratch drive for swap and junk
Buying a second, faster SSD that I could freely trash with swap.
After the HDD that came with this laptop became suspiciously slow, I bought a 1TB SATA SSD to move my data to. I copied the contents over and did some GRUB2 magic to get it booting, and enjoyed the speedy mass storage life. However, after hearing all the stories of limited write endurance, I was worried about trashing it too early, with various caches and most importantly swap. I did not use swap at all, which was slightly annoying with “only” 16GB of RAM and a Google-made browser.
Some time later, likely during cleaning, I found a M.2 slot in the laptop. This gave me an idea to get a second NVMe drive to store swap. NVMe would be faster than SATA, which is definitely appreciated for swap space, and because it’d be a dedicated, smaller, cheaper drive I would not be worried at all about destroying it with writes.
I bought a Goodram* 250GB NVMe drive, hoping it would work. I am in no way
a hardware person, and the keying system (especially the
removing-pins-to-add-features idea, wtf) was confusing to me. Thankfully it
worked, and soon /dev/nvme0n1 spawned on my system.
I split it into a 48GiB swap partition, and a 185GiB “scratch” partition. Almost 50GiB of swap felt like already more than enough, and the “scratch” partition would be more useful if I could fit large files on it. The idea behind it, inspired by scratch tapes, is to have dedicated space for large, volatile data with reasonably fast access.
This seems to work quite well! As I write this, free claims 14 out of 15.5GiB
of main RAM is used, and 16 out of 48GiB of swap is used. From idly monitoring,
I am now near constantly using more RAM than I had before.
Yes, when I start up a VM kswapd0 will wake up and the computer will thrash
for a second or sixty, but this is the point of swap – something will get swapped out,
and nothing will crash and there will be no need to dispatch a random Chromium
process. I haven’t seen the OOM killer around in while either.
The scratch partition gets slightly less use, but still some. I did not
get around to moving the entirety of ~/.cache, and the browser seems to not
really care about the --disk-cache-dir="/mnt/scr/.cache/chromo" I passed,
but I have moved and symlinked a few cache directories already, and used the
space for temporary but large processes, like preparing MP3 CDs for my car.
It is now mounted under /mnt/scr, which I aliased under zsh to ~s.
When (if) I reinstall the OS, I will likely set up the cache correctly from the get-go, I am scared to do it right now due to likely random incompatibilities and browsers’ tendency to nuke their cookie jars and settings at the instant something goes slightly wrong with their config folders. Starting on a fresh setup will make this easier.
Are there any security drawbacks to posting partition UUIDs? I don’t think so,
here’s the /etc/fstab setup for my future reference. Feel free to steal.
# nvme0n1p2 AKA scratch
UUID=90d0b2f2-0907-4126-a257-89d90a9a05a5 /mnt/scr ext4 rw,noatime,commit=120,discard 0 0
# nvme0n1p2 aka nuswap
UUID=7f88596f-7429-4a8f-9e52-dec0c10475cb none swap defaults,pri=100 0
* Not an ad nor recommendation, picked nearly at random.