fix(ansible): optimize root trim policy

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
ja
2026-04-02 16:15:32 +02:00
co-authored by Junie
parent bbdcd43e01
commit 6ff790fd4b
3 changed files with 116 additions and 0 deletions
+39
View File
@@ -57,6 +57,45 @@
become: yes become: yes
tags: [swap, optimization] tags: [swap, optimization]
- name: Check current root mount options
command:
argv:
- findmnt
- -no
- OPTIONS
- /
register: root_mount_options
changed_when: false
tags: [filesystem, optimization, trim]
- name: Ensure root filesystem uses periodic TRIM settings in fstab
mount:
path: /
src: "UUID={{ root_filesystem_uuid }}"
fstype: ext4
opts: "{{ root_filesystem_mount_opts }}"
passno: 1
dump: 0
state: present
become: yes
tags: [filesystem, optimization, trim]
- name: Reload systemd after fstab updates
systemd:
daemon_reload: yes
changed_when: false
become: yes
tags: [filesystem, optimization, trim]
- name: Remount root filesystem without continuous discard
mount:
path: /
opts: "{{ root_filesystem_mount_opts }},nodiscard"
state: remounted
when: "'discard' in (root_mount_options.stdout.split(','))"
become: yes
tags: [filesystem, optimization, trim]
- name: Optimize kernel parameters - name: Optimize kernel parameters
sysctl: sysctl:
name: "{{ item.name }}" name: "{{ item.name }}"
+2
View File
@@ -1,5 +1,7 @@
# mw-pfeddersheim-workstation variables # mw-pfeddersheim-workstation variables
system_user: mw system_user: mw
root_filesystem_uuid: 2aeade2e-b169-4964-8cbd-bb7356320b51
root_filesystem_mount_opts: noatime
swap_file_path: /swapfile swap_file_path: /swapfile
swap_file_size_gb: 16 swap_file_size_gb: 16
workspace_root: /home/mw/infrastructure/mw-pfeddersheim-workstation workspace_root: /home/mw/infrastructure/mw-pfeddersheim-workstation
+75
View File
@@ -0,0 +1,75 @@
---
description: >-
TRIM policy optimization for the mw-pfeddersheim-workstation after the
Samsung PM9A1 firmware update to GXA7801Q.
tags:
- storage
- trim
- nvme
- ansible
- optimization
last_updated: '2026-04-02'
---
# TRIM Optimization After PM9A1 Firmware Update
## Summary
On 2026-04-02 the workstation TRIM policy was aligned with current Linux best
practice for ext4.
- Root filesystem (`/`) on `/dev/nvme0n1p2` was changed from `noatime,discard`
to `noatime` in `/etc/fstab`
- Weekly `fstrim.timer` remains enabled and active
- Continuous ext4 discard was disabled at runtime with a remount using
`nodiscard`
## Why This Change Was Necessary
The root ext4 filesystem was configured with continuous `discard` while the
system already had periodic TRIM enabled via `fstrim.timer`.
For ext4, continuous discard adds overhead to unlink and truncate operations.
With a healthy weekly `fstrim.timer`, it is redundant on this workstation.
## Implementation
The persistent change was implemented in Ansible.
- `ansible/vars/main.yml`
- added `root_filesystem_uuid`
- added `root_filesystem_mount_opts: noatime`
- `ansible/roles/common/tasks/main.yml`
- ensured the root fstab entry is managed with `mount: state=present`
- checked current root mount options with `findmnt`
- remounted `/` without continuous discard when needed
## Verification
### fstab
```text
UUID=2aeade2e-b169-4964-8cbd-bb7356320b51 / ext4 noatime 0 1
```
### Periodic TRIM
```text
ActiveState=active
UnitFileState=enabled
NextElapseUSecRealtime=Mon 2026-04-06 00:49:28 CEST
```
### Validation Steps
```text
ansible-playbook ansible/workstation.yml --check --tags trim
ansible-playbook ansible/workstation.yml --tags trim
findmnt --verify --tab-file /etc/fstab
```
## Notes
- `/boot/efi` remains unchanged
- This change only targets the ext4 root filesystem TRIM policy
- Firmware and benchmark documentation remain in the NVMe benchmark documents