best way to configure an SSD for swap space in Linux?

cantab

Junior Member
Nov 30, 2009
3
0
0
I have an i7-950 system with 12 gig RAM running Matlab under Linux. 12 gig is not enough, so my code is using swap space. I'd like to swap to a solid state drive.

My question is, what is the best way to configure the SSD, and the Linux kernel and system, to minimize the overhead of paging RAM in and out?

Thanks!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I don't know if any specific tips or tricks since I don't have an SSD but a quick look at the latest linux git source tree shows that swapfile.c calls the appropriate blkdev_issue_discard function to TRIM the space on swapon.

However, if you've really got 1 process wanting a ton more memory than you physically have I wouldn't be surprised if you still ended up getting the OOM killer after it. How much memory are you looking to need?
 

cantab

Junior Member
Nov 30, 2009
3
0
0
I've seen people say before not to swap to an SSD, but why not?

I need 24 gig of memory, which would cost $2500 as DDR3 RAM. Swapping to a magnetic disk, my Matlab process terminates fine, and does not thrash, but is slow.

Is there a particular Linux file system that is best for swap disks? Or is there some way of using the SSD for swap that directly involves SSD pages rather than pretending the SSD is a file system?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I've seen people say before not to swap to an SSD, but why not?

I need 24 gig of memory, which would cost $2500 as DDR3 RAM. Swapping to a magnetic disk, my Matlab process terminates fine, and does not thrash, but is slow.

Is there a particular Linux file system that is best for swap disks? Or is there some way of using the SSD for swap that directly involves SSD pages rather than pretending the SSD is a file system?

Ah ok, if it works ok with a normal disk then it should still complete with an SSD, only faster.

Linux supports paging to full block devices and swap files so a filesystem is optional. You either just create a swap partition and use 'mkswap' to initialize it and 'swapon' to actually use it. Or create a filesystem, then create an empty file with something like 'dd' then 'mkswap' and 'swapon' that file.
 

jimhsu

Senior member
Mar 22, 2009
705
0
76
If he's running out of main memory, I doubt a ram drive is much use.

The only possible reason to not swap to SSDs is that sequential writes have a chance of blocking (i.e preventing reads simultaneously). If your workload writes GB sized files and expects the system to be responsive at that time, that may be a problem. With RANDOM writes, any decent SSD should handle that fine.
 
Last edited: