Linux

Table of Contents

The linux distribution used since 2019 in local computers is Linux Mint.

Moved homepc to Arch on 2023-11-25. Later a second desktop homepc2 was added with the same Arch OS snapshot. Later Installed Alpine Linux in end July 2024 on homepc2 and this the current OS on homepc2 and pi.

homepc is however back to Linux Mint and Thinkpad T480 is also currently running Linux Mint.

Lenova E41-25 gone through multiple linux variants like Linux Mint, Zorin, Fedora and finally has gone back to Windows 11 in late'25.

Optimisations

To reduce wear on nvme/ssd i'm using zswap actively in the following ways. This absorbs swap activity in RAM without hitting the NVMe

Zswap setup

  • Kernel cmdline: `zswap.enabled=1 zswap.compressor=lzo zswap.max_pool_percent=25`
  • Swap device: `/dev/nvme0n1p3` (4 GB partition)
  • tmpfs used for `~/.cache` dirs to avoid SSD writes

Challenge

The output seen in `free -m` / `/proc/swaps` "used" swap is logical, not physical disk writes. zswap compresses pages in RAM first; only overflow gets written to the real swap device.

The command to check swap device info

cat /proc/swaps

Verification commands

To verify that the above settings are really avoiding writes to nvme, there are few tests.

Some steps use vmstat commands which need `procps-ng` package in Alpine Linux.

Check live swap-in/out activity (si/so columns)

vmstat 1 5

The following script checks zswap pool stats + /proc/swaps + block stats.

#!/bin/sh
# Quick zswap / swap writeback check
# Usage: ./zswap-check.sh

doas sh -c '
  mount -t debugfs none /sys/kernel/debug 2>/dev/null
  echo "--- zswap ---"
  echo "stored_pages:        $(cat /sys/kernel/debug/zswap/stored_pages)"
  echo "pool_total_size:     $(cat /sys/kernel/debug/zswap/pool_total_size)"
  echo "written_back_pages:  $(cat /sys/kernel/debug/zswap/written_back_pages)"
  echo "reject_reclaim_fail: $(cat /sys/kernel/debug/zswap/reject_reclaim_fail)"
'

echo "--- /proc/swaps ---"
cat /proc/swaps

echo "--- nvme0n1p3 block stats (field5=write I/Os, field7=sectors written) ---"
cat /sys/class/block/nvme0n1p3/stat

Real per-process swap usage can be checked using the below script.

for f in /proc/[0-9]*/status; do
  awk '/^Pid|^Name|^VmSwap/{printf "%s ", $2}END{print ""}' "$f"
done | awk '$3!="0" {print}' | sort -k3 -h -r | head -20

An additional Hardware-level confirmation can be done to check actual writes to swap partition.

cat /sys/class/block/nvme0n1p3/stat

The following fields in the above results are vital:

Field Meaning
5 write I/Os completed
7 sectors written

Both should stay 0. Note that the information is cumulative since boot.

Expected outcome

If there is no write occurs to nvme/ssd, the following results are expected for the above verification steps.

  • `written_back_pages`: 0
  • `vmstat` si/so: 0 (no active swap traffic)
  • `nvme0n1p3` write I/Os: 0, sectors written: 0

If the above results are seen, then it can be concluded that all "swap" usage was absorbed by zswap in RAM; no SSD writes occurred.

Setup working as intended.

Date: 2023-04-20 Thu 17:39

Author: Prabu Anand Kalivaradhan

Created: 2026-10-11 Sun 15:24