LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Do I need a swap file to run linux? (https://www.linuxquestions.org/questions/linux-software-2/do-i-need-a-swap-file-to-run-linux-648967/)

Rick069 06-12-2008 10:56 PM

Do I need a swap file to run linux?
 
Is there a relation between a linux swap file and ram? I have 6gb of ram and I'm wondering if I need a swap file.

jschiwal 06-12-2008 11:10 PM

A swap file is used to save memory before going into hibernation. Some programs may assume the presence of swap. A very small swap partition should keep everything happy. Disk space is much cheaper than ram. Having a 1GB swap file shouldn't hurt.

One caveat is that if you have an eepc you don't want to have a swap file. Flash based filesystems have a limited number of writes.

i92guboj 06-12-2008 11:13 PM

Quote:

Originally Posted by Rick069 (Post 3183270)
Is there a relation between a linux swap file and ram? I have 6gb of ram and I'm wondering if I need a swap file.

The amount of ram you have is not relevant. What's really relevant is the amount of ram you are going to use. If you have 6gb but you are going to run something that will be filling them them you need swap. If you have 256mb but you are going to run only a firewall on a headless box then you don't need swap.

The thing is simple as that. So, if you are lost, you could try defining the load that that box will have. For a regular desktop you are not going to hit swap easily with that amount of ram. Still, it doesn't hurt to have a one or two gigabytes partition lying around just in case. Note that, if the ram fills up, the kernel will swap, but if there's no swap space, it will just start killing programs without any consideration, and at that point, you might scream if it closes a document that you haven't saved for hours (not that you should do that, but things are not always as they should).

Some hibernation methods use swap to save an image of the ram. So, if you are going to use such a thing you will need to have a swap partition that's at least as big as your ram unless the image can be saved on a compressed form. I don't use hibernation so I don't really know much about that.

chrism01 06-13-2008 12:42 AM

Yep, the swap partition gives you a grace period if the RAM fills up. The disk starts to thrash and the box becomes noticeably slower, but you can still do something about it... assuming you are sitting there at the time of course ...


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