Should the “discard” option be used for mounting a swap file?
The Arch Wiki says that defaults,discard
can be used in the fstab
file for a swap partition. However it is not clear about a swap file, nor is the man page.
If the swap file resides in a filesystem which itself is mounted with the discard
option (and is obviously in an SSD), should it use discard
itself? And what if the parent filesystem is not discard
'ing?
Intuition says "no", but I could not find anything about it and thought it was worth discussing.
filesystems mount swap trim
bumped to the homepage by Community♦ 4 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
The Arch Wiki says that defaults,discard
can be used in the fstab
file for a swap partition. However it is not clear about a swap file, nor is the man page.
If the swap file resides in a filesystem which itself is mounted with the discard
option (and is obviously in an SSD), should it use discard
itself? And what if the parent filesystem is not discard
'ing?
Intuition says "no", but I could not find anything about it and thought it was worth discussing.
filesystems mount swap trim
bumped to the homepage by Community♦ 4 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I am wondering the same thing. Did you find an answer to your question?
– Pierre Spring
May 9 '18 at 12:48
1
@PierreSpring I didn't; but I settled with periodic discards instead by enablingfstrim.timer
with systemd. The timer simply callsfstrim -av
once a week. You can read more at wiki.archlinux.org/index.php/Solid_State_Drive#TRIM.
– Marc.2377
May 10 '18 at 0:10
add a comment |
The Arch Wiki says that defaults,discard
can be used in the fstab
file for a swap partition. However it is not clear about a swap file, nor is the man page.
If the swap file resides in a filesystem which itself is mounted with the discard
option (and is obviously in an SSD), should it use discard
itself? And what if the parent filesystem is not discard
'ing?
Intuition says "no", but I could not find anything about it and thought it was worth discussing.
filesystems mount swap trim
The Arch Wiki says that defaults,discard
can be used in the fstab
file for a swap partition. However it is not clear about a swap file, nor is the man page.
If the swap file resides in a filesystem which itself is mounted with the discard
option (and is obviously in an SSD), should it use discard
itself? And what if the parent filesystem is not discard
'ing?
Intuition says "no", but I could not find anything about it and thought it was worth discussing.
filesystems mount swap trim
filesystems mount swap trim
asked Jun 1 '17 at 1:45
Marc.2377Marc.2377
298324
298324
bumped to the homepage by Community♦ 4 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 4 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I am wondering the same thing. Did you find an answer to your question?
– Pierre Spring
May 9 '18 at 12:48
1
@PierreSpring I didn't; but I settled with periodic discards instead by enablingfstrim.timer
with systemd. The timer simply callsfstrim -av
once a week. You can read more at wiki.archlinux.org/index.php/Solid_State_Drive#TRIM.
– Marc.2377
May 10 '18 at 0:10
add a comment |
I am wondering the same thing. Did you find an answer to your question?
– Pierre Spring
May 9 '18 at 12:48
1
@PierreSpring I didn't; but I settled with periodic discards instead by enablingfstrim.timer
with systemd. The timer simply callsfstrim -av
once a week. You can read more at wiki.archlinux.org/index.php/Solid_State_Drive#TRIM.
– Marc.2377
May 10 '18 at 0:10
I am wondering the same thing. Did you find an answer to your question?
– Pierre Spring
May 9 '18 at 12:48
I am wondering the same thing. Did you find an answer to your question?
– Pierre Spring
May 9 '18 at 12:48
1
1
@PierreSpring I didn't; but I settled with periodic discards instead by enabling
fstrim.timer
with systemd. The timer simply calls fstrim -av
once a week. You can read more at wiki.archlinux.org/index.php/Solid_State_Drive#TRIM.– Marc.2377
May 10 '18 at 0:10
@PierreSpring I didn't; but I settled with periodic discards instead by enabling
fstrim.timer
with systemd. The timer simply calls fstrim -av
once a week. You can read more at wiki.archlinux.org/index.php/Solid_State_Drive#TRIM.– Marc.2377
May 10 '18 at 0:10
add a comment |
1 Answer
1
active
oldest
votes
I would say no.
1: The swap space does not use the same concept of free space as filesystem
2: what matter is that you always keep at least 25% free space on your SSD (this value was given to me by Sandisk representative on the phone), to allow proper work of wear levelling.
=> as long as the disk has spare clusters to work with, and to perform WL, it does not really matter if 5% of your disk is never trimmed, or continusouly re-written: even when YOU rewrite the same logical or physical sectors, WL will use different clusters anyway, when you write large enough blocks.
The question remains unanswered if you are using a whole disk for swapping. A whole disk used for swap may suffer premature aging, if never trimmed.
The other question is: does the swap driver support discard ? ext3/ext4 do.
Maybe, if your swap occupies a significant % of the disk, if you can, you could discard/trim the swap space during shutdown: if you can, after killing all services, do swapoff, and find a way to discard the swapspace (since I am not an expert, and to not leave the question unanswered, I would propose to mkfs.ext3, fstrim, mkswap again - there are probably other better solutions. Check if shutdown is due to UPS. ).
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f368456%2fshould-the-discard-option-be-used-for-mounting-a-swap-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I would say no.
1: The swap space does not use the same concept of free space as filesystem
2: what matter is that you always keep at least 25% free space on your SSD (this value was given to me by Sandisk representative on the phone), to allow proper work of wear levelling.
=> as long as the disk has spare clusters to work with, and to perform WL, it does not really matter if 5% of your disk is never trimmed, or continusouly re-written: even when YOU rewrite the same logical or physical sectors, WL will use different clusters anyway, when you write large enough blocks.
The question remains unanswered if you are using a whole disk for swapping. A whole disk used for swap may suffer premature aging, if never trimmed.
The other question is: does the swap driver support discard ? ext3/ext4 do.
Maybe, if your swap occupies a significant % of the disk, if you can, you could discard/trim the swap space during shutdown: if you can, after killing all services, do swapoff, and find a way to discard the swapspace (since I am not an expert, and to not leave the question unanswered, I would propose to mkfs.ext3, fstrim, mkswap again - there are probably other better solutions. Check if shutdown is due to UPS. ).
add a comment |
I would say no.
1: The swap space does not use the same concept of free space as filesystem
2: what matter is that you always keep at least 25% free space on your SSD (this value was given to me by Sandisk representative on the phone), to allow proper work of wear levelling.
=> as long as the disk has spare clusters to work with, and to perform WL, it does not really matter if 5% of your disk is never trimmed, or continusouly re-written: even when YOU rewrite the same logical or physical sectors, WL will use different clusters anyway, when you write large enough blocks.
The question remains unanswered if you are using a whole disk for swapping. A whole disk used for swap may suffer premature aging, if never trimmed.
The other question is: does the swap driver support discard ? ext3/ext4 do.
Maybe, if your swap occupies a significant % of the disk, if you can, you could discard/trim the swap space during shutdown: if you can, after killing all services, do swapoff, and find a way to discard the swapspace (since I am not an expert, and to not leave the question unanswered, I would propose to mkfs.ext3, fstrim, mkswap again - there are probably other better solutions. Check if shutdown is due to UPS. ).
add a comment |
I would say no.
1: The swap space does not use the same concept of free space as filesystem
2: what matter is that you always keep at least 25% free space on your SSD (this value was given to me by Sandisk representative on the phone), to allow proper work of wear levelling.
=> as long as the disk has spare clusters to work with, and to perform WL, it does not really matter if 5% of your disk is never trimmed, or continusouly re-written: even when YOU rewrite the same logical or physical sectors, WL will use different clusters anyway, when you write large enough blocks.
The question remains unanswered if you are using a whole disk for swapping. A whole disk used for swap may suffer premature aging, if never trimmed.
The other question is: does the swap driver support discard ? ext3/ext4 do.
Maybe, if your swap occupies a significant % of the disk, if you can, you could discard/trim the swap space during shutdown: if you can, after killing all services, do swapoff, and find a way to discard the swapspace (since I am not an expert, and to not leave the question unanswered, I would propose to mkfs.ext3, fstrim, mkswap again - there are probably other better solutions. Check if shutdown is due to UPS. ).
I would say no.
1: The swap space does not use the same concept of free space as filesystem
2: what matter is that you always keep at least 25% free space on your SSD (this value was given to me by Sandisk representative on the phone), to allow proper work of wear levelling.
=> as long as the disk has spare clusters to work with, and to perform WL, it does not really matter if 5% of your disk is never trimmed, or continusouly re-written: even when YOU rewrite the same logical or physical sectors, WL will use different clusters anyway, when you write large enough blocks.
The question remains unanswered if you are using a whole disk for swapping. A whole disk used for swap may suffer premature aging, if never trimmed.
The other question is: does the swap driver support discard ? ext3/ext4 do.
Maybe, if your swap occupies a significant % of the disk, if you can, you could discard/trim the swap space during shutdown: if you can, after killing all services, do swapoff, and find a way to discard the swapspace (since I am not an expert, and to not leave the question unanswered, I would propose to mkfs.ext3, fstrim, mkswap again - there are probably other better solutions. Check if shutdown is due to UPS. ).
answered Dec 3 '18 at 14:42
Benoit-Pierre DEMAINEBenoit-Pierre DEMAINE
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f368456%2fshould-the-discard-option-be-used-for-mounting-a-swap-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am wondering the same thing. Did you find an answer to your question?
– Pierre Spring
May 9 '18 at 12:48
1
@PierreSpring I didn't; but I settled with periodic discards instead by enabling
fstrim.timer
with systemd. The timer simply callsfstrim -av
once a week. You can read more at wiki.archlinux.org/index.php/Solid_State_Drive#TRIM.– Marc.2377
May 10 '18 at 0:10