Ask Your Question
1

What's bleeding edge in terms of swap?

asked 2015-11-21 23:17:46 -0600

florian gravatar image

Hi,

since I am using GNU Linux', I have always created a swap partition (something like same size as installed RAM) but I've never seen it in use - always empty. Currently, that is may be due to the fact that I have 8GB RAM that I am apparently never maxing out. So, I consider the swap partition a waste of space. How could I improve, and how do you guys do it? Swap file instead? How then? Or just no swap space?

Thanks!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-11-22 09:29:16 -0600

masteroman gravatar image

Well what I do is create 2 GB zram partition in ram that I use for swap with highest priority which first compresses things that go in swap. Besides that I also have 1 GB swap file with lower priority as a backup. Here are the scripts I use to manage zram device.

IMHO there is no need to occupy 8 GB of disk space just for a swap partition when you can use that space for something else and just create swap file (shameless self-promotion) with size that fits your needs.

edit flag offensive delete link more

Comments

Hi, Thanks for your answer. Interesting setup that you created there - makes sense to me. I was also thinking about a swap file. Do I understand correctly that the swapfile does not grow dynamically? It remains the size that you create it ( dd if=/dev/zero of=/swapfile bs=1M count=1024)? Isn't there a way to start with an empty swapfile (size 0) and let it grow as it's needed?

florian gravatar imageflorian ( 2015-11-22 09:35:44 -0600 )edit
1

Hey @Florian . Well you can always turn off swap file, recreate it with different size and then turn it back on. There is also a possibility to add additional swap files as needed, just create another swap file and turn it on, though I rarely even swap to the swap file since zram compresses it with ratio 1:2 depending on what goes to the swap.

Anyway, in ideal world you would never want to swap to disk anyway since it's generally slow, but swap is there to escape "Out-of-memory" scenario.

masteroman gravatar imagemasteroman ( 2015-11-22 10:21:11 -0600 )edit

I really like the idea of a zram partition in RAM, and having a small swapfile as backup on HDD. I guess, I will set that up. Thanks for providing the scripts!

florian gravatar imageflorian ( 2015-11-23 10:34:56 -0600 )edit
0

answered 2015-11-22 06:27:58 -0600

geforce gravatar image

Whats the problem with just having a normal 8GB swap partition as harddrives space virtually costs nothing?

edit flag offensive delete link more

Comments

That statementis probably right for a desktop PC. I should have mentioned that I am talking about my notebook which is small Thinkpad (X201) that fits one HDD. I do have 250GB SSD, and currently I am not willing to invest in a 500GB SSD. Now, 250GB is really not that much - I think 8GB do matter here. Especially, since I have never seen the swap in use I consider it waste of space. (And I never feel the need to hibernate my notebook. It's either on, off, or in standby - that's all I need).

florian gravatar imageflorian ( 2015-11-22 09:25:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-21 23:17:46 -0600

Seen: 444 times

Last updated: Nov 22 '15