Trim for SWAP on SSD

Originally titled:

> Anything for the weekend with your trim sir?

Ok, I have read (TBH am still reading) this:

https://wiki.archlinux.org/title/Solid_state_drive#Periodic_TRIM

I’ve fully read upto and including this:

On the ext4 filesystem, the `discard` flag can also be set as a [default mount option](https://wiki.archlinux.org/title/Access_Control_Lists#Enable_ACL) using *tune2fs*:
# tune2fs -o discard /dev/sd**XY**

However, when i tried that tune2fs command on my swap partition it didn’t work, viz:

[marvin@the door ~]$ sudo tune2fs -o discard /dev/sda4
tune2fs 1.46.5 (30-Dec-2021)
tune2fs: Bad magic number in super-block while trying to open /dev/sda4
/dev/sda4 contains a swap file system labelled 'swap'

So i skip read to the end and there doesn’t seem to be any mention of settings when a swap drive is an SSD.

Help! Please tell me i don’t need to ask Debbie McGee.

That is because it is a swap partition and not an esxt4 partition.

Generally speaking, enabling the fstrim timer is all you need to do to get trimming running on all your partitions which support trim. systemctl enable --now fstrim.timer

You shouldn’t need to set discard flags.

Also, I will reiterate what someone else said in another topic that you are much more likely to get proper attention and better help if you use descriptive titles.

1 Like

Sorry @dalto my brain has stopped working but i really should have realised that myself, Mea culpa. Ditto my bad re the thread headline, which i have now changed.

1 Like

Screenshot from 2022-07-08 17-13-00

:question:

:thought_balloon:
:penguin:

Anyway, enabling that timer should be all you need for periodic trim in most cases.

Honest. I did change it.
Although i might then have updated a post too before saving.
Sorry i’m trying to read ten things at once and think what else i need or missed and, until i few mins ago, in a house of chaos (my daughter & her fam are staying with me atm so we are rather over-crowded with complete insanity too).

Altered post header for the second time (and this time i checked).
Just a thought, is there a smiley for a Deliverance style grin?

No problem.
Please check the solution box under @dalto’s first post for the forum software to regard the topic as solved.

Uhh,… I don’t know.
But there is one for being :relieved:

Have a nice well-trimmed Weekend!

Thanks @dalto

Done:

systemctl enable --now fstrim.timer

Thanks for the simple solution

1 Like

Not well trimmed yet @pebcak as i’m still waiting for the first invocation - i think that’s a religious thing.

I will certainly flag that solution.
Thanks for reminding my hairless airhead.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.