New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options for swap discarding (TRIM) #108948
Conversation
Isn't this change the same as adding following configuration? (unless
If |
allowDiscards = mkOption { | ||
default = false; | ||
type = types.bool; | ||
description = "cryptsetup argument --allow-discard on open"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this explains how it works but not what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I copied the allowDiscards description from luksroot. Thank you!
I copied allowDiscards from luksroot
Only luksroot had allowDiscards, not the general 'encrypted-devices.nix'. I didn't know I could override options for swap that way either. Does that work? Maybe it should say 'swap0'? I'm using this change this way:
I agree. I copied the documentation from luksroot.nix |
You should change the names according to your partition naming. I haven't tested it, but it should work. Is it a good idea to mount |
On Sun, Jan 10, 2021 at 03:26:28PM -0800, bb2020 wrote:
> Only luksroot had allowDiscards, not the general 'encrypted-devices.nix'. I didn't know I could override options for swap that way either. Does that work? Maybe it should say 'swap0'?
Is it a good idea to mount `swap` with `discard`? It may stall disk operations. I would prefer mounting `/` with `discard` and running periodic `fstrim` on swap area.
The manpage (swapon) says that the TRIM runs asynchronously, so maybe they
will not stall. In any case, I could add discard options (once, pages,
both), if you want.
…--
(Escriu-me xifrat si saps PGP / Write ciphered if you know PGP)
PGP key 7CBD1DA5 - https://emailselfdefense.fsf.org/
|
with --allow-discards. | ||
|
||
If you use encrypted.enable for this swap device, you should enable | ||
there encrypted.allowDiscards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be done automatically, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm I'm not sure how. Any suggestion?
How does this relate to #107728? |
Oh, that looks like the official way to achieve this. |
Looks like changes in #107728 will work only with unencrypted swap, so discards still should be enabled in in luks. |
It is good to see #107728 is merged.
I suppose you can use LVM to create TRIM on LUKS should not be enabled by default as there are security implications. It is explained here. It should be up to the user. |
Here I added PR for this: #129408
I'd prefer not to use LVM as I don't need it and use btrfs subvolumes instead.
Right, it's disabled by default via |
Motivation for this change
swap on ssd will benefit from TRIM/discard so the writes to the ssd go faster with less wearing.
It works in my encrypted swap0.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)