Back to site

Optimize NVMe disks

Reduce SSD wear and improve I/O with fstrim, noatime, and iostat.

Optimize NVMe disks

NVMe drives offer very low latency, but poor tuning (unnecessary writes, missing TRIM) can degrade long-term performance. This guide covers safe optimizations on a HolyCloud Linux VPS.

Prerequisites

  • Linux VPS with NVMe or SSD storage (check with lsblk and nvme list if available)
  • root or sudo access
  • Snapshot or backup before editing /etc/fstab

Identify disk and filesystem

List devices and root mount:

lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,MODEL
findmnt /
df -hT /

Typical NVMe volume: /dev/nvme0n1p1 mounted as ext4 or xfs.

Enable TRIM with fstrim

TRIM tells the SSD which blocks are free. On most recent distributions, fstrim.timer is already active:

systemctl status fstrim.timer
systemctl enable --now fstrim.timer

Manual run (safe on supported read-write filesystems):

fstrim -av

For a specific mount:

fstrim -v /

Reduce writes: noatime in fstab

By default, Linux updates atime on every read, causing extra SSD writes. Back up then edit /etc/fstab:

cp -a /etc/fstab /etc/fstab.bak.$(date +%F)
grep -v '^#' /etc/fstab

Replace defaults with defaults,noatime (or add noatime to existing options) for the root line, for example:

UUID=xxxx-xxxx  /  ext4  defaults,noatime  0  1

Apply without reboot:

mount -o remount,noatime /
findmnt -o OPTIONS /

Note: relatime is often the modern default; noatime goes further. Avoid continuous discard on some setups — prefer periodic fstrim.

Monitor I/O with iostat

Install sysstat if needed:

apt update && apt install -y sysstat

Live metrics (2 s interval, 5 samples):

iostat -xz 2 5

Useful indicators:

  • %util near 100%: disk saturated
  • High await: significant I/O latency
  • r/s / w/s: read/write throughput

Daily history (after enabling sysstat):

sed -i 's/ENABLED="false"/ENABLED="true"/' /etc/default/sysstat
systemctl enable --now sysstat
sar -d 1 3

Additional checks

Check a suitable scheduler (often none or mq-deadline on NVMe):

cat /sys/block/nvme0n1/queue/scheduler

Check alignment and space (ext4):

tune2fs -l /dev/nvme0n1p1 | grep -E 'Block count|Reserved block'

Troubleshooting

| Symptom | Action |

|----------|--------|

| fstrim: Operation not supported | Check TRIM support: lsblk -D |

| Mount won't remount | Restore /etc/fstab.bak and mount -a |

| Constant high I/O | iotop -o to find the process |

Need help?

For repartitioning or migration to a larger volume, open a ticket from your HolyCloud customer area.