LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation
User Name
Password
Slackware - Installation This forum is for the discussion of installation issues with Slackware.

Notices


Reply
  Search this Thread
Old 11-13-2012, 02:17 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
How much swap for 4GB RAM, if any?


Slackware 14.0

In the Slackware-HOWTO file, Volkerdi says: "If you machine doesn't have a lot of RAM, you'll want another partition for swap space". Does this mean that if you do (have a lot of RAM) then you do not need a swap partition? I'm installing 14.0 and the machine has 4GB RAM.
 
Old 11-13-2012, 02:27 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
I have 4GB of ram.
I have a swap of 4GB to allow hibernating my laptop, but other than that, it doesn't get used.
Obviously, it depends how you use YOUR pc, so maybe set one up & if you find it is not useful, you can remove it later.
Or go without, and if it's a problem, add some later.

Choice is good
 
Old 11-13-2012, 02:35 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
The two choices are in fact one and the same for, if I allocate only 1G thinking I have time later to add 1G more, where do I get that 1G extra once I partioned the whole disk? Unless I add a 2nd disk.
 
Old 11-13-2012, 03:10 AM   #4
cascade9
Senior Member
 
Registered: Mar 2011
Location: Brisneyland
Distribution: Debian, aptosid
Posts: 3,753

Rep: Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935
You can shrink partitions to make more space.

Its probably easier to just setup 4GB swap space from the start. Unless you've got a small HDD its what I would do.
 
Old 11-13-2012, 06:19 AM   #5
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by stf92 View Post
The two choices are in fact one and the same for, if I allocate only 1G thinking I have time later to add 1G more, where do I get that 1G extra once I partioned the whole disk? Unless I add a 2nd disk.
You can also use swap files, they have a slight performance penalty but they do work.
 
Old 11-13-2012, 06:21 AM   #6
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Well, with 4GB RAM and 500GB disk, following a rule of thumb I found somewhere (2 * RAM + 1GB for exceptional situations than can slow down the machine while using GUI) I created 9GB swap. Now, 9 / 500 = 1.8 per cent of total disk, which seems to be steeling it not to much space.

Later on, I'll consider if I shrink it to a smaller size, a thing easily done with (c)fdisk by erasing first the whole partition and then creating it the new size. Thanks for giving your valuable opinion which, on the other hand, matches that of Volkerdi in the Slackware-HOWTO, when he speaks about swap size = RAM size.
 
Old 11-13-2012, 06:28 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
The only reason for a swap partition is to suspend to disk / hibernate. There is no other reason, so if you don't suspend to disk there is no need for swap.
 
Old 11-13-2012, 06:44 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by stf92 View Post
Well, with 4GB RAM and 500GB disk, following a rule of thumb I found somewhere (2 * RAM + 1GB for exceptional situations than can slow down the machine while using GUI) I created 9GB swap. Now, 9 / 500 = 1.8 per cent of total disk, which seems to be steeling it not to much space.
Those ancient rules of thumbs were useless in the beginning and are useless now. There is only one way to determine the amount of swap you need: You have to test it with your workload. On a modern machine with normal desktop use you are safe with just using the amount of RAM, if you want to use hibernate, or just use 1GB, which is enough for most cases and doesn't matter on modern disk sizes.

Quote:
Originally Posted by H_TeXMeX_H
The only reason for a swap partition is to suspend to disk / hibernate. There is no other reason, so if you don't suspend to disk there is no need for swap.
That is not really true. If you need swap still depends on your RAM. I have a laptop that has 2GB of RAM and it has a swap partition, that is used by the system to swap out RAM that is used by applications running in the background, but are almost always idling. This speeds up the system, since it makes more space for caching files in RAM. With systems in the range <4GB RAM, IMHO, this is useful and desired behavior.
I even have a 1GB swap partition on my main machine with 16GB RAM and it is occasionally used.

In short: If you need a swap partition and what its size should be can only be determined by your size of RAM and the workload you intent to run. General thumbs of rule are pretty worthless, but we can give you at least some recommendations from experience.
 
1 members found this post helpful.
Old 11-13-2012, 06:55 AM   #9
Knightron
Senior Member
 
Registered: Jan 2011
Location: Australia
Distribution: openSUSE
Posts: 1,465
Blog Entries: 6

Rep: Reputation: 200Reputation: 200Reputation: 200
Is there a log that monitors swap usage at all?
 
Old 11-13-2012, 07:08 AM   #10
cascade9
Senior Member
 
Registered: Mar 2011
Location: Brisneyland
Distribution: Debian, aptosid
Posts: 3,753

Rep: Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935
Quote:
Originally Posted by stf92 View Post
Well, with 4GB RAM and 500GB disk, following a rule of thumb I found somewhere (2 * RAM + 1GB for exceptional situations than can slow down the machine while using GUI) I created 9GB swap. Now, 9 / 500 = 1.8 per cent of total disk, which seems to be steeling it not to much space.
Just for your info, a 500GB HDD isnt actually 500GB. Well, technically it is 500GB if you go for that MB/MiB 1000x1000x1000/1024x1024x1024 nonsense. I dont.

A 500GB HDD will actually be about 465GB. Or 465GiB if you like the whole MB/MiB thing.

http://en.wikipedia.org/wiki/Mebibyte
http://en.wikipedia.org/wiki/Megabyte

*edit- the 'swap = 2 x RAM' idea is very old, and there has been people pointing out that for years now-

http://www.cyberciti.biz/tips/linux-swap-space.html

Every time I see people say that 'swap size should be RAM x 2' I shudder. Its been repeated so many times that its even more annoying to me than seeing people post 'how tos' for debian using sudo commands....

Last edited by cascade9; 11-13-2012 at 07:11 AM.
 
Old 11-13-2012, 07:17 AM   #11
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by TobiSGD View Post
In short: If you need a swap partition and what its size should be can only be determined by your size of RAM and the workload you intent to run. General thumbs of rule are pretty worthless, but we can give you at least some recommendations from experience.
That is what bothers me. The dependence of swap size on RAM size is nice, because this does not vary. But, I cannot guess the type of application I'll give my machine the day of tomorrow (= some day in the future). So I must provide for the worst scenario, i.e., maximum workload. Of course, it would be a good thing for me what are the kind of jobs which imposes great workloads. Perhaps my machine will be doing such jobs not even in its wildest dreams.

A valid question is, I think: can too much swap space conspire against system performance? If the answer is "no", what do I lose by using ten times the RAM if my disk has the space?
 
Old 11-13-2012, 07:57 AM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by stf92 View Post
... what do I lose by using ten times the RAM if my disk has the space?
The only thing you lose is the disk space.
 
Old 11-13-2012, 08:37 AM   #13
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by stf92 View Post
That is what bothers me. The dependence of swap size on RAM size is nice, because this does not vary. But, I cannot guess the type of application I'll give my machine the day of tomorrow (= some day in the future). So I must provide for the worst scenario, i.e., maximum workload. Of course, it would be a good thing for me what are the kind of jobs which imposes great workloads. Perhaps my machine will be doing such jobs not even in its wildest dreams.

A valid question is, I think: can too much swap space conspire against system performance? If the answer is "no", what do I lose by using ten times the RAM if my disk has the space?
There shouldn't be a performance impact with having much swap space. But consider this: If you come up in the future with a workload that makes your machine use huge amounts of swap you would be better of with buying a more RAM, since using swap for large chunks of memory will have a serious impact on performance. RAM is cheap nowadays and there is only one thing that is better than RAM: more RAM.
 
Old 11-13-2012, 09:41 AM   #14
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
The reason why I don't use swap anymore is because when the system runs out of RAM, because some program eats it up, I do NOT want my computer to slow to a crawl as it is swapping like mad. I just want it to kill the damn program and let me get back to doing what I was doing. I have messed with the various swap settings and I have decided that having swap in the first place is not very useful and in fact may be wasteful in most cases -- a waste of space and time waiting for your computer to stop swapping. I do not have enough applications running in the background and using any significant amount of RAM. If you run a server, then things may be different, but you will also have a lot more RAM.

My conclusion is for a desktop computer that does not suspend to disk, there is no use for swap.
 
Old 11-15-2012, 12:24 AM   #15
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
I've always been told you takes the RAM size and Double it to get your Swap size.

4GB RAM = 8 GB Swap Partition
 
  


Reply



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
Finding out what RAM chip needed to upgrade from 2GB to 4GB RAM. farmerluk Linux - Hardware 4 11-17-2011 12:02 PM
Why size of swap space is 2x of RAM??? Why not 1.5x of RAM or 2.5x of RAM??? Saurav Ghosh Linux - Newbie 7 11-01-2011 03:49 AM
4GB RAM Ubuntu 9.04 pitanaya Linux - Laptop and Netbook 14 09-17-2010 09:48 PM
3.6GB RAM instead of 4GB ??? masterross Slackware 11 09-04-2008 08:07 AM
4GB RAM not showing eddie0uk Linux - Hardware 5 03-12-2005 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation

All times are GMT -5. The time now is 09:09 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration