Harden both NAS08 and NAS16 to extend SSD lifespan by ensuring TRIM is running correctly, noatime is active, and SMART health is being monitored — with all scheduled jobs visible in OMV's scheduler for easy management.
lsblk --discard /dev/sda
Confirm DISC-GRAN and DISC-MAX are non-zero before enabling TRIM.
Both units: DISC-GRAN 4K / DISC-MAX 4G — TRIM fully supported on all drives.
systemctl status fstrim.timer
Determine whether a TRIM schedule already existed before creating a new one.
Both units: timer active and enabled, running weekly. NAS08 next run Monday 12:33 AM — NAS16 next run Monday 1:37 AM.
journalctl -u fstrim.service --no-pager
Verify the timer was actually running and catching all mounted volumes.
Both units: / and /boot/firmware trimmed successfully on May 11 and May 18. NAS08 ~400 GiB freed per run. NAS16 ~228 GiB on first run, 3.3 GiB on second (less free space).
findmnt -t ext4,xfs,btrfs -o TARGET,SOURCE,OPTIONS
Confirm noatime was already set on all filesystems to prevent reads generating writes.
Both units: every mount point already showing noatime — handled automatically by the openmediavault-flashmemory plugin. No action required.
sudo smartctl -A /dev/sda sudo smartctl -A /dev/sdb # NAS08 data drives
Identify vendor-specific SMART attribute names before writing the monitoring script — attribute names differ significantly between PNY and Crucial.
NAS08 PNY CS900: uses SSD_Life_Left (attr 231), Bad_Blk_Ct_Lat/Erl (attr 170), no pending/uncorrectable attrs. NAS08 Crucial BX500: uses Percent_Lifetime_Remain (attr 202), Reallocate_NAND_Blk_Cnt (attr 5), Reported_Uncorrect. NAS16 drive: uses standard attribute names — no vendor mapping required.
noatime: Already active on all filesystems on both units via the openmediavault-flashmemory plugin. No manual configuration required.
Swap disabled, logs in tmpfs: Also handled automatically by the flashmemory plugin — swap off, /var/log and /tmp in RAM, reducing write amplification significantly.
The systemd fstrim.timer was already running weekly on both units but was invisible in OMV's scheduler. It was replaced with an OMV Scheduled Job so all jobs are visible and manageable in one place.
A custom script was written to replace the bare fstrim call with a full monitoring run that emails an HTML report matching the KingDezigns backup monitor style (dark header, badge/banner, section rows, cards, footer).
The email report includes: TRIM results per volume with total bytes freed, SSD SMART health per drive (health, temperature, wear, power-on hours, sector counts), filesystem usage with colour-coded warnings at 75% and 90%, and system info (OMV version, kernel, IP, uptime, load, memory, next run time).
/usr/scripts/omv/fstrim-report.sh
/var/log/fstrim/fstrim-YYYY-MM-DD.log (90-day retention)
sudo nano /usr/scripts/omv/fstrim-report.sh # paste script content, save with Ctrl+O, exit with Ctrl+X sudo chmod +x /usr/scripts/omv/fstrim-report.sh
sudo systemctl start fstrim.service sudo journalctl -u fstrim.service -f
sendmail -t (via OMV's configured SMTP relay)
Initial script used generic attribute names. Two rounds of fixes were needed after testing:
Round 1 — Crucial BX500 fix: Reallocated: Reallocated_Sector → Reallocate_NAND_Blk_Cnt Pending: Current_Pending_Sector → Current_Pending_ECC_Cnt Uncorrect: Offline_Uncorrectable → Reported_Uncorrect Temperature: $10 → $10+0 (strips "32 (Min/Max 25/56)" format) Round 2 — PNY CS900 fix: Wear: Wear_Leveling_Count → SSD_Life_Left Reallocated: Reallocate_NAND_Blk_Cnt → Bad_Blk_Ct_Lat/Erl (first value before /)
Each pattern now tries vendor-specific names first, then falls back to generic names — script works correctly on any brand.
The systemd fstrim.timer was disabled on both units and replaced with OMV Scheduled Jobs so all scheduled tasks are visible in one place.
sudo systemctl disable fstrim.timer sudo systemctl stop fstrim.timer
Prevent the systemd timer from running alongside the new OMV job — avoids double execution.
Timer stopped and disabled on both NAS08 and NAS16.
sudo rm /etc/systemd/system/fstrim.service.d/override.conf sudo systemctl daemon-reload
Clean up the override that pointed fstrim.service to the script — no longer needed since OMV cron calls the script directly.
Override removed, systemd reloaded cleanly on both units.
System → Scheduled Jobs → Add Command: /usr/scripts/omv/fstrim-report.sh User: root NAS08: Wednesday at 1:00 AM NAS16: Wednesday at 1:30 AM
Wednesday was chosen as it sits midweek, away from Sunday ZFS scrubs and the rolling every-3-day backup jobs.
Both units now show TRIM Report in OMV scheduler alongside all other scheduled jobs.
NAS08
| Schedule | Script | Tag |
|---|---|---|
| Every 3 days at 2:00 AM | /usr/scripts/omv/nas08-backup.sh | NAS08 Backup |
| Daily at 12:00 AM | /usr/scripts/zfs/nas08_zfs_report.sh | ZFS Status Report |
| Sunday at 3:00 AM | /usr/scripts/zfs/nas08_zfs_scrub.sh | ZFS Scrub |
| Wednesday at 1:00 AM | /usr/scripts/omv/fstrim-report.sh | TRIM Report |
NAS16
| Schedule | Script | Tag |
|---|---|---|
| Every 3 days at 2:00 AM | /usr/scripts/omv/nas16-backup.sh | NAS16 Backup |
| Every 2 days at 2:30 AM | bash /usr/scripts/nas/nas08_to_nas16_sync.sh | NAS Drive Backup |
| Daily at 12:00 AM | /usr/scripts/zfs/nas16_zfs_report.sh | ZFS Status Report |
| Sunday at 3:00 AM | /usr/scripts/zfs/nas16_zfs_scrub.sh | ZFS Scrub |
| Every 15 minutes | /usr/scripts/ddns/ddns_update.sh | DDNS Update |
| Wednesday at 1:30 AM | /usr/scripts/omv/fstrim-report.sh | TRIM Report |
| Lesson | Detail |
|---|---|
| Always investigate before configuring | Both noatime and fstrim were already handled by OMV's flashmemory plugin — checking first avoided duplicating work. |
| SMART attribute names are vendor-specific | PNY and Crucial use completely different attribute names for wear, reallocated sectors, and temperature format. Always run smartctl -A /dev/sdX first to map the real names. |
| systemd timers are invisible in OMV scheduler | The default fstrim.timer runs correctly but doesn't appear in OMV's job list — migrate to OMV Scheduled Jobs for full visibility alongside ZFS scrubs and backups. |
| Never run script without sudo for testing | Running fstrim-report.sh without sudo causes permission denied on /var/log/fstrim/ and returns N/A for all SMART data — always test with sudo or via systemctl start. |
| Use sudo nano over cp for file edits | Preferred method for placing and editing scripts on the NAS — faster navigation to the correct path, avoids confusion about source file location. |
| Inline TRIM (discard mount option) is not recommended | Real-time per-delete TRIM adds latency under heavy load. Periodic batch TRIM via fstrim is the correct approach for NAS workloads. |
| PNY CS900 has no pending/uncorrectable attributes | N/A for those fields is correct and expected — not a script bug. The drive simply does not expose those attributes. |
| File | What changed |
|---|---|
server_nas08.md |
Added drive inventory table, full SSD Hardening & Maintenance section (TRIM, noatime, flashmemory plugin, SMART attribute mapping), and complete OMV Scheduled Jobs table. |
server_nas16.md |
Added drive inventory table with Power_Cycle_Count monitoring note, full SSD Hardening & Maintenance section, and complete OMV Scheduled Jobs table including NAS drive backup sync job. |