Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Apparently at some point over 3GB of RAM was being used and the system needed to put something in swap. To be honest, I'm not seeing anything unusual there.
Quote:
Originally Posted by anishakaul
Does it mean no swap partition has been created ???
The fact that there is an entry for Swap in the total column means that yes, a swap partition was created. It just wasn't being used.
The fact that there is an entry for Swap in the total column means that yes, a swap partition was created. It just wasn't being used.
Isn't it surprising that no swap is being used at all ?
In which case does this happen ?
In my computer whenever I do "free" swap column is never shown 0 !
Isn't it surprising that no swap is being used at all ? In which case does this happen ?
Actually, no it isn't surprising, particularly with 4GB of RAM. I've got 4GB on my main laptop and I've never seen swap used. Heck, on my netbook I've got 2GB of RAM and never created a swap partition and it runs without a problem. Linux is actually pretty intelligent about how it uses RAM and since swap is glacially slow compared to RAM it doesn't use it unless it has to.
Quote:
In my computer whenever I do "free" swap column is never shown 0 !
Well, swap usage is a function of how much RAM is available and what services are running. The fact that I don't even have swap on my netbook reflects that it has a decent amount of RAM relative to the work I do with it. It runs things like a browser and word processor. If I were trying to serve tons of web pages or run databases on it, the lack of swap would likely be a problem. I've got a similar amount of RAM on my server and that is almost always using some swap, but that is running Apache, MySQL, SAMBA and a few other things.
Most of the above discussion ignores the important interaction between swap and cache.
Linux keeps recently read pages in cache. That includes pages of data files your applications may have read as well as pages of read only file mappings (such as .so file and the main executable) that have been faulted out of a process's working set but not all the way out of physical ram.
If something needs memory and swap space is not available, then Linux must take that memory by reducing the cache. Sometimes that results in worse performance than if the swap space had been available.
If something needs memory and swap space is available, Linux will still usually take from the cache rather than swap pages out to swap space. But most systems have some processes that are either idle or have stale anonymous data, so there are anonymous data pages whose most recent access is significantly older than the most recent access of any read only mappings in the cache. Then it makes sense to swap those idle pages out to swap space in order to keep the cache large.
So, with plenty of ram and little enough file I/O and read only mapping that the cache never grows big enough to take most of the free memory, obviously the swap will never be used.
However with plenty of ram so the system never "needs" to use swap, but with enough recent file I/O or read only mapping that the cache is "full" (free memory outside the cache minimal) and also everything in the cache is newer than some stale anonymous pages, then Linux will correctly use some swap space even though it doesn't "need" to.
Yes you could. If you have 4 GB of ram and are using a 32bit distro, you have as much real ram as address space unless you use a PAE kernel. Many programs and services will use some memory when they are starting up but the memory may not be used again. Memory like that that doesn't used for a long time may get swapped out freeing more real memory for your applications. Also the swap partition is used if you suspend your computer. The rule of thumb I use for over 2 GB of ram is to make the swap partition a bit larger then the amount of ram. Drives are very large now so it shouldn't be missed.
I guess my rule of thumb is that if you have decent disk space, you should probably have some swap from the get-go. Yes, you can add a swap partition after install (provided you can re-partition your drive), but it is usually easier to do that at install time. There are a couple of reasons why I didn't put a swap partition on my netbook. First, it has a 16GB drive and I need every last GB of that for software. Second, the 16GB drive is an SSD and I wanted to eliminate as many read/write cycles as possible to preserve the drive life.
Quote:
Originally Posted by jschiwal
Also the swap partition is used if you suspend your computer
You're right you do need swap to hibernate your computer (suspend to disk), but I don't think you need it to suspend to RAM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.