Disk Trimming

This guide is very difficult to follow for someone who don’t understand all these things about LVM LG LV HVM thin pool etc. And there are a lot of conditionals too. I will try to make a summary of what is necessary for someone with an up to date stable qubes os system with the default settings. R4.2.4.

First step is doing systemd or cron in dom0. I guess it doesn’t matter if it’s systemd or cron if you want weekly trims. I probably want daily but I will go with weekly in this post because I will ask a question about it soon for learning. So in dom0 I will start xterm and do:

    systemctl enable fstrim.timer
    systemctl start fstrim.timer

After that is done I should enable cron trims in all the qubes. Or is it all qubes really? Including disposables? So inside each qube in their xterm as root: create a trim file in /etc/cron.daily and add the following contents:

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

And mark it as executable with chmod 755 /etc/cron.daily/trim

Is everything correct so far? It doesn’t matter dom0 uses systemd weekly trim but each qube uses daily cron trim?

How should I know if I have qubes with LVM? I don’t even know what this is. But I am going to make a guess that everyone have qubes with LVM by default. It’s the normal/standard/recommended way. Because I assume we all use LVM in qubes, next step is to set issue_discards = 1 in /etc/lvm/lvm.conf.

The last step is about trim for SWAP. The guide says it’s not enabled be defaut in r4 and r4.1 but doesn’t say about r4.2. But the guide says how to check:

To verify that TRIM is enabled, check dmesg for what flags were enabled when the swap space was activated.

And it seems not enabled for me by default so maybe the guide can be updated and add that it’s still not enabled by default in r4.2.4

This mean I need to add the discard=once option to the options for the swap entry in /etc/fstab. Then I can redo the above check and the it should be correct hopefully.

That should be all that is needed to do in summary to enable trim in qubes os 4.2.4. But seeing the replies in this topic make it seem like there is a good chance there is going to be some troubleshooting needed as well.

2 Likes