You are not logged in.

#1 2015-02-21 18:35:04

onslow77
Member
Registered: 2014-09-21
Posts: 279

[SOLVED] How to implement TRIM when swap is started with systemd?

Hello,

When the swap partition is started with systemd, does it also automatically use the "--discard" option if the disk is a ssd with TRIM support?

I know I can add swap to "fstab" with the "discard option" and cange the "system id 82"... to prevent systemd mount. But that is not my goal, and I have not found any conclusive information for TRIM usage when swap is activate by systemd - a nodge in the right direction would greatly be appreciated.

Tryed if I could use fstrim instead  for my swap partition, but to no avail:

# fstrim -v /dev/sda3
fstrim: /dev/sda3: not a directory

Regards
Martin

Last edited by onslow77 (2015-02-21 22:54:42)


It is advised to follow the How to post guide when posting on the Arch forum. If one consciously jumps over these elementary steps like reading the wiki and providing necessary information about the problem, one can be regarded as a Help Vampire.

Offline

#2 2015-02-21 19:44:11

Foucault
Member
From: Athens, Greece
Registered: 2010-04-06
Posts: 214

Re: [SOLVED] How to implement TRIM when swap is started with systemd?

I had the same problem and I found no reasonable answer to this. The only viable solution was to set the flag 63 (do not automount) to my swap partition and manage swap from fstab as usual. It's easy to do that with sgdisk.

Note! This assumes GPT partitioned disks, I do not know if it's possible on MBR partitioned disks, although I doubt that systemd automounts swap on MBR partitioned disks anyway.

# sgdisk -A [partition number]:set:63 /dev/sdX

For example if swap is /dev/sda4 you need to issue

# sgdisk -A 4:set:63 /dev/sda

It worked for me. If there is any other less hacky solution I would love to know it as well. There should be some fix upstream as per this bug report (systemd-gpt-auto-generator should not mount swap again if it's managed by fstab) although I don't think it has landed on current systemd used in arch.

Last edited by Foucault (2015-02-21 19:53:54)

Offline

#3 2015-02-21 20:17:50

teateawhy
Member
From: GER
Registered: 2012-03-05
Posts: 1,138
Website

Re: [SOLVED] How to implement TRIM when swap is started with systemd?

There is also this bug report:
https://bugs.freedesktop.org/show_bug.cgi?id=87230
"No way to configure systemd-gpt-auto-generator, or mask unwanted vendor's generators by user"
Which is fixed:

Generators are made maskable in commit http://cgit.freedesktop.org/systemd/sys … e801700e9a. Some documentation updates are in order, but generally
  ln -s /dev/null /etc/systemd/system-generators/<name>
does the trick.

So you might be able to solve this with:

 ln -s /dev/null /etc/systemd/system-generators/systemd-gpt-auto-generator

Offline

#4 2015-02-21 22:54:10

onslow77
Member
Registered: 2014-09-21
Posts: 279

Re: [SOLVED] How to implement TRIM when swap is started with systemd?

Hello,

Thank you "Foucault" and "teateawhy" for your time and help. I went with the solution to set my swap flag to 63 (do not automount), and now my swap partition loads correctly from fstab with the "discard" option for TRIM support. Not what I first aimed at, but it got the job done.

Regards
Martin

Last edited by onslow77 (2015-02-21 22:56:26)


It is advised to follow the How to post guide when posting on the Arch forum. If one consciously jumps over these elementary steps like reading the wiki and providing necessary information about the problem, one can be regarded as a Help Vampire.

Offline

Board footer

Powered by FluxBB