LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 09-07-2011, 10:11 PM   #1
wulp
LQ Newbie
 
Registered: Mar 2011
Posts: 8

Rep: Reputation: 0
Should TRIM be used on SWAP partition?


I have a swap partition. Should I add the "discard" option to /etc/fstab to enable TRIM on the swap partition?
 
Old 09-07-2011, 10:23 PM   #2
andrewthomas
Senior Member
 
Registered: May 2010
Location: Chicago Metro
Distribution: Arch, Gentoo, Slackware
Posts: 1,690

Rep: Reputation: 307Reputation: 307Reputation: 307Reputation: 307
http://en.wikipedia.org/wiki/TRIM#Di...meter_in_Linux

Are you using a SSD?

If you have a regular HD also, your swap partition should be on that.
 
Old 09-07-2011, 10:51 PM   #3
wulp
LQ Newbie
 
Registered: Mar 2011
Posts: 8

Original Poster
Rep: Reputation: 0
It is an SSD.
 
Old 09-07-2011, 11:02 PM   #4
andrewthomas
Senior Member
 
Registered: May 2010
Location: Chicago Metro
Distribution: Arch, Gentoo, Slackware
Posts: 1,690

Rep: Reputation: 307Reputation: 307Reputation: 307Reputation: 307
I think that you would benefit from reading this wiki article:

https://wiki.archlinux.org/index.php/SSD
 
Old 09-08-2011, 03:44 PM   #5
jefro
Guru
 
Registered: Mar 2008
Posts: 10,991

Rep: Reputation: 1355Reputation: 1355Reputation: 1355Reputation: 1355Reputation: 1355Reputation: 1355Reputation: 1355Reputation: 1355Reputation: 1355Reputation: 1355
Do you really need a swap file or partition?
 
Old 09-10-2011, 01:00 PM   #6
wulp
LQ Newbie
 
Registered: Mar 2011
Posts: 8

Original Poster
Rep: Reputation: 0
@andrew Thanks for the link, although it is really long winded and doesn't look like it will answer my question. Why don't people use discard on the swap partition? Don't files in the swap get deleted? Everything I read on this is just hearsay. From my view, it looks like a potential storage leak, but I don't really know.

@jefro Swap is useful for extended hibernation. I'm the kind of person that opens up 20 windows at a time and will leave them that way for days or more. Also, hibernation is more useful than the last 8GB of space on my SSD, which would otherwise just be used for wear leveling.
 
Old 09-10-2011, 09:34 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,042

Rep: Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970
this looks a reasonably good, current article. And answers the question.
A quick search of lkml confirms (automatic) discard support was patched into swapon in 2008.
 
1 members found this post helpful.
Old 09-11-2011, 07:49 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,042

Rep: Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970
Sorry, looks like the kernel dev responsible for this has changed the behaviour again.
2.6.29 (-ish) introduces the above. 2.6.36 removed it again, and introduced a userspace option for user control. After that it seems you'll need to use discard in fstab.

(I don't have any SSD to test on).

Last edited by syg00; 09-11-2011 at 07:51 AM.
 
1 members found this post helpful.
Old 09-11-2011, 07:55 AM   #9
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Gentoo
Posts: 15,346
Blog Entries: 2

Rep: Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978
Quote:
Originally Posted by syg00 View Post
Sorry, looks like the kernel dev responsible for this has changed the behaviour again.
2.6.29 (-ish) introduces the above. 2.6.36 removed it again, and introduced a userspace option for user control. After that it seems you'll need to use discard in fstab.

(I don't have any SSD to test on).
Thanks for that info. I do have a SSD, but how do I test if discard works on the swap-partition?
 
Old 09-11-2011, 08:06 AM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,042

Rep: Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970
Dunno .... :shrug:
I'd suspect it'll work as designed, but whether it'll be beneficial is the concern. Have a read of this. Must be a (benchmark ?) test for it some-where.
 
Old 09-11-2011, 08:23 AM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Gentoo
Posts: 15,346
Blog Entries: 2

Rep: Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978
If I read that correctly performance decreases when discard is set on swap (not that I would notice, I rarely use swap), so I will not set that flag. Thanks for the link.
 
Old 09-11-2011, 07:45 PM   #12
sgosnell
Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian
Posts: 333

Rep: Reputation: 59
A reason to use swap is to enable hibernation/suspend. If you have a laptop, those are very useful options, and won't work without swap space. Personally, I don't have discard in my swap line in fstab, and haven't seen the need for it. I do use it on / and /home, though.
 
Old 12-07-2012, 09:17 AM   #13
avalonit
Member
 
Registered: Jun 2008
Posts: 70

Rep: Reputation: 17
Quote:
Originally Posted by sgosnell View Post
Personally, I don't have discard in my swap line in fstab, and haven't seen the need for it. I do use it on / and /home, though.
Care to explain what's the difference between discard on swap or any other filesystem? Right, swap is smaller so impact is lower but it's always better to give more space for SSD to optimize wear leveling. btw not sure if swapon cares about fstab options, because putting invalid options there returns no warnings or errors. I'm trying to figure out what the proper way of enabling trim is.

update: sounds like it is always enabled [1].

[1] http://docs.fedoraproject.org/en-US/...ssdtuning.html

Last edited by avalonit; 12-07-2012 at 03:04 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
swap file vs. swap partition verndog Ubuntu 16 07-09-2012 08:49 PM
swap file or swap partition? What is better? zemir Linux - Newbie 28 08-19-2011 09:15 PM
Can swap file or a swap partition be mounted and read? Mr-Bisquit Linux - General 3 06-08-2009 02:16 PM
Hard Drive Partition Management - Mandriva Double Partition with Swap File partition moshebagelfresser Linux - Hardware 2 05-23-2008 10:46 AM
Newbie Installing Debian3 on m68k w/250M Partition Needs help creating swap partition AppleMac Linux - Newbie 2 11-01-2002 08:45 AM


All times are GMT -5. The time now is 04:39 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration