What's the default SSD Trim status on QubesOS 4.2?

I remember having to manually do some config for enabling the SSD trimming in QubesOS 4.1. With 4.2, is SSD trimming enabled by default?

sudo dmesetup table | grep luks-<your UUID> on 4.2 reports allow_discards, so everything is configured.

You only need to add /sbin/fstrim -a to weekly crontab.

1 Like

Can you tell me how I do this?

Just add a trim file to /etc/cron.weekly directory.
And in trim file put:

#!/bin/bash
/sbin/fstrim --all

After that, add executable flag to that file with chmod +x /etc/cron.weekly/trim.

(Based on this forum post)

Your link also mentions that one should add this cronjob script to each qube separately. Is enabling the trimming from dom0 also trim the unused disk spaces of individual domUs?

Edit: also, do I use sudo with the chmod command of yours?

dom0 already has continuous trim enabled with the discard mount option in /etc/fstab. Don’t enable both continuous and periodic trimming at the same time. Either remove the discard option and enable fstrim.timer, or keep the current default.

2 Likes

OK. Keeping current default sounds better. I guess that answers the thread’s question: Dom0 disk trimming is enabled by default.

Follow up questions:

  1. do I need to enable trimming inside the individual domU qube templates?
  2. what about the RAM trimming? Is this enabled by default?
1 Like
  1. It’s also enabled there by default.
  2. Xen manages this part and should free the memory each time a qube is stopped.
1 Like

AFAIK the discard mount option for / in dom0 will only trim the partition used to run dom0 system.

There is no reason for this setting to apply to the qubes LVM pool. It seems one should enable issue_discards = 1 in dom0 /etc/lvm/lvm.conf to make LVM discard old data.

See related thread https://www.reddit.com/r/Proxmox/comments/po4du9/ensuring_trim_works_through_whole_storage_stack/ and man page https://linux.die.net/man/5/lvm.conf