Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do I make sure Linux has as much virtual memory as it needs? Will it automatically use HD space for virtual memory, or must I tell it to do so? And either way, if an operating system can use virtual memory, then isn't it possible to have a large amount of RAM without adding any more RAM boards, limited only by the amount of free HD space? I think I've never understood this about virtual memory.
Linux uses the "swap" partition for this. If you don't define one, Linux will take up as much of your root partition as it needs (probably, haven't checked it).
See also
Code:
man swapon
Quote:
if an operating system can use virtual memory, then isn't it possible to "have a large amount of RAM" without adding any more RAM boards, limited only by the amount of free HD space
Why did you think virtual memory was invented? Exactly for this reason: to extend the always limited amounted of physical RAM by using up disk space (which is usually MUCH larger) instead.
Any program you run will actually get to see an amount of memory which is always <= the sum of the amounts of physical memory and virtual memory (<= hard disk free space).
Downside is that accessing the hard disk is much slower than accessing a memory chip, so your system performance will degrade if your system is constantly swapping (=using virtual memory).
As to how operating systems (OS) handle virtual memory, that's a whole different story.
If you don't define one, Linux will take up as much of your root partition as it needs (probably, haven't checked it).
No, it won't. The kernel likes to swap out certain things occasionally, even when you have available physical memory and should you not have a defined swap partition or swap file you will see out of memory errors.
Quote:
accessing the hard disk is much slower than accessing a memory chip
Correct. Many, many, many times slower, thousands of times slower. Swapping constantly is something to avoid at all costs.
what you need to do to get more is to make another partition using fdisk or something. Then you should run 'mkswap /dev/hdax' and 'swapon /dev/hdax' assuming that your partition is on the master primary ide.
(1) Chips are cheap now. Find out how much physical RAM your machine can hold and stuff it.
(2) Allocate swap partitions (if possible) about twice the size of physical RAM.
(3) If you have more than one drive, especially on different channels that can perform I/O simultaneously, distribute your swap space across several spindles.
Extraordinary use of memory by an application strongly suggests the presence of "a bug."
Allocate swap partitions (if possible) about twice the size of physical RAM
I read that you should not go above a 512mb swap partition, does this rule still apply, because with the above if you had 1gb memory then you would have a 2gb swap.
@Michael_aust, the "swap size = 2x RAM size" rule is just a rule-of-thumb. If you really need 2GB (which is quite a lot) of swap when you already have 1GB of RAM is doubtful, but it really depends on what you want to do with your system. For a basic desktop system with no fancy games or graphical stuff, your 1GB RAM should do most of the work anyway, so you don't really need the 2GB of swap.
But, as hard disks grow in size constantly, why not just apply the rule anyway? What harm will losing 2GB do to you, if you have a hard disk of 100+ GB?
If you apply the 2xRAM size rule, at least you should be safe in practically any situation.
@newbies_forever:
Surely you mean 256MB of RAM, not 256KB? The days of measuring RAM in KB are long gone, I'd say...
Even though your physical slots are occupied, you could still consider switching one (or both) of the DIMMs for a larger one. However, if you do so, keep in mind:
-the operating frequency of your system bus and of your memory.
For optimal operation, the FSB frequency should be an integer multiple of the operating frequency of your
memory.
-any limitations on RAM size imposed by your motherboard.
-keep an eye out for the RAM technology (DRAM, SDRAM, etc) as this can make quite a lot of difference performance-wise.
But, as hard disks grow in size constantly, why not just apply the rule anyway? What harm will losing 2GB do to you, if you have a hard disk of 100+ GB?
If you apply the 2xRAM size rule, at least you should be safe in practically any situation.
II thought if you have a stupid amount of swap space that you will most likely suffer performance problems because the system will spend all of its time swapping (taken from a book im reading which claims this is called thrashing)
II thought if you have a stupid amount of swap space that you will most likely suffer performance problems because the system will spend all of its time swapping (taken from a book im reading which claims this is called thrashing)
is this correct, would thios end up happening?
Not unless you run out of physical memory. The kernel will always choose physical memory over virtual but swap isn't _just_ for virtual memory, the kernel also swaps out other data which is just how it works, it's not negatively impacting performance. The negative hit comes when you run out of physical memory (RAM) and the kernel has to use virtual memory (swap) because of the reasons mentioned above.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.