diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index 809296d..1346475 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -57,6 +57,45 @@ become: yes 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 sysctl: name: "{{ item.name }}" diff --git a/ansible/vars/main.yml b/ansible/vars/main.yml index 31d2529..ea5e5ae 100644 --- a/ansible/vars/main.yml +++ b/ansible/vars/main.yml @@ -1,5 +1,7 @@ # mw-pfeddersheim-workstation variables system_user: mw +root_filesystem_uuid: 2aeade2e-b169-4964-8cbd-bb7356320b51 +root_filesystem_mount_opts: noatime swap_file_path: /swapfile swap_file_size_gb: 16 workspace_root: /home/mw/infrastructure/mw-pfeddersheim-workstation diff --git a/docs/tech/trim-optimization-2026-04.md b/docs/tech/trim-optimization-2026-04.md new file mode 100644 index 0000000..42dd686 --- /dev/null +++ b/docs/tech/trim-optimization-2026-04.md @@ -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 \ No newline at end of file