LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what if there is no swap partition (https://www.linuxquestions.org/questions/linux-newbie-8/what-if-there-is-no-swap-partition-4175462849/)

nameprabhat 05-21-2013 05:26 AM

what if there is no swap partition
 
Please let me know, can a server boot without having any swap partition?

Regards, Prabhat

Ser Olmy 05-21-2013 05:28 AM

Sure, as long as there's enough RAM.

syg00 05-21-2013 05:44 AM

Booting without swap is never (o.k., rarely) an issue. Start using memory and, welllll .... who knows.

shivaa 05-21-2013 06:04 AM

In simple words server will boot, but it also depends that what kind of server it is and whether you'll need swap space or not. Swap space temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory for active processes and there is insufficient unused physical memory available.

For more details, here: https://help.ubuntu.com/community/SwapFaq

ozar 05-21-2013 06:51 AM

Quote:

what if there is no swap partition
Hello

I've not used a swap partition in the last 8 or 9 years on my desktop machines (lots of RAM), but if I were running a server that would become very busy after it boots, I'd want to use one. It would be better to have it an not need it than it would be to need it and not have it.

TB0ne 05-21-2013 10:04 AM

Quote:

Originally Posted by nameprabhat (Post 4955623)
Please let me know, can a server boot without having any swap partition?
Regards, Prabhat

The easiest way to find out would be for you to build a Linux system without a swap partition, and see what happens. This sounds very much like a homework question, so doing/learning on your own would be best.

jefro 05-22-2013 03:29 PM

Ser Olmy points out basically the correct answer. Yes, it can boot if other conditions are true. To simply boot, one would have to have some minimum ram amount available. That amount would vary greatly depending on how the distro is made and the kernel and services and boot options and even hardware and bios settings.


In many cases you can easily add in a swap partition or "swap file" with very little effect. One can use multiple swap partitions and multiple swap files. Even swap raid can be used and one can set priority on how sway is selected.


Some odd programs will use swap if available even if you have enough ram.


If in doubt, a modern distro can have a swap area added just to be safe. As noted above, many people don't use swap anymore.

Nbiser 05-22-2013 04:00 PM

You shouldn't need a swap partition as long as there is enough RAM in your system. The purpose of the RAM in the first place is to store currently running programs and processes: the purpose of swap is to store some of these programs and processes if your RAM overflows. As long as you have plenty of RAM you shouldn't need SWAP, in other words.

suicidaleggroll 05-22-2013 04:02 PM

Swap is only needed if you run out of RAM. If you never run out of RAM, then you never need swap space. It's nice to have something there "just in case" though, you never know when an innocent process might run away with your RAM due to some oversight.

Just the other day I ran a "diff -r" on two directories on a remote server. They were big directories, so I left it and started working on something else. A couple of hours later I came back and found the machine responding VERY slowly. I ran "top", and saw that my diff was using all 24 GB of RAM on the machine, and the OS had pushed nearly every other process into the swap. I immediately killed the diff and over the course of 1-2 minutes the system pulled what it needed back out of swap and the system started running normally again. Without a swap partition, things probably would have ended very differently.

chrism01 05-22-2013 06:28 PM

Yeah, the dreaded OOM-Killer would have kicked in ;)

Armann 05-22-2013 07:25 PM

I'm currently reading Michael Jang's RHCSA/RHCE sixth edition.
Quote from the book.
"Linux moves infrequently used programs and data to swap space even if you have gigabytes of RAM."

Just thought I would throw that one in... ;)

suicidaleggroll 05-22-2013 07:28 PM

Quote:

Originally Posted by Armann (Post 4956883)
I'm currently reading Michael Jang's RHCSA/RHCE sixth edition.
Quote from the book.
"Linux moves infrequently used programs and data to swap space even if you have gigabytes of RAM."

Just thought I would throw that one in... ;)

Unless you set swappiness to 0 or don't have a swap partition.
Nobody said that the swap is never used if you have available RAM, we're saying that not having a swap won't cause a problem if you have available RAM, which is what the OP asked.

mike_rhce 05-22-2013 09:08 PM

Incidentally, it is possible to set up a swap file on Linux, e.g. http://www.cyberciti.biz/faq/linux-a...ap-file-howto/ . Of course, you can also set up a swap volume.

If you don't have any swap space (swap partition, volume, or file), Linux simply is not able to move infrequently used programs to that area.

Armann 05-23-2013 07:51 AM

Quote:

Originally Posted by suicidaleggroll (Post 4956885)
Unless you set swappiness to 0 or don't have a swap partition.
Nobody said that the swap is never used if you have available RAM, we're saying that not having a swap won't cause a problem if you have available RAM, which is what the OP asked.

Cool didn't know that, where do you set "swappiness" to 0 in CentOS ?

shivaa 05-23-2013 08:02 AM

Quote:

Originally Posted by Armann (Post 4957198)
Cool didn't know that, where do you set "swappiness" to 0 in CentOS ?

For more details on swappiness, check link provided in post#4


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