Board logo

標題: Swap 空間 -- linux [打印本頁]

作者: createch    時間: 2011-11-26 04:27     標題: Swap 空間 -- linux

最近有一個 server hang 機, system support 通知我們是由於 "out of memory".

我入去 console check 左, 原來個 web hosting 只提供 1G Ram, 而 swap partiition 只有 1G.

我即時將個 swap 增大至 2G (乜個 server admin  set server 時唔知個 basic principle 係 swap 要等同 Ram 的 2 倍 ??)

以下是一則有關文章, 以供大家參考..
===========================
A computer running GNU/Linux generally has a few different partitions on it (not including any Windows or other OS dual boot scenarios). There’s usually a small Master Boot Record (MBR) partition which houses your boot loader (usually GRUB or Lilo); a system partition which houses your actual OS (usually quite large), and there’s usually a swap partition.

I have another paritition which I use as my home directory, but that’s kind of a specialized, yet common, set up.

The swap partition is used to help your system run faster. When your system runs out of physical RAM during operations, it uses the swap partition as RAM and writes little bits of stuff that is currently in RAM, but not needed, to the swap partition. This allows you to run more programs at once. The alternative to having swap is…well…not having swap. In this scenario, when you’ve opened up enough applications that your physical memory fills up, there’s no place to write the overflow and your system will bog down quite miserably.

Most modern OSes have some sort of swap facility. In Windows this is referred to as the pagefile, and I’m not sure what it’s referred to as on a Mac.

So, the answer seems obvious, doesn’t it? Swap is good. You should have swap and worship it every day.

I can’t argue with that. Swap is good, but in many systems it’s not necessary. I discovered this completely by accident one day. I muffed up the partitioning when I installed Kubuntu and didn’t allocate a swap partition. The funny thing is that I didn’t notice for months and when I did notice it was by conversing with someone who asked me something about my swap, not due to any system performance issues.

Prior to this incident, I didn’t think it was possible to run a GNU/Linux box without swap, but it turns out that not only is it possible, some people do it on purpose.

In the home/desktop world, if you have a GB of RAM or more, your system may never swap anything out. The recommendations for allocating swap is anywhere from 1.5 to 2 times the amount of physical RAM on your system. On some systems, losing 2 to 3 GB of disk space might be a considerable loss and therefore not worth it.

In the server world, running without swap is propbably suicidal. Don’t do that.

If you’re curious, check out your swap usage now and again. With KDE you can use KDE System Guard and there are some gDesklets available for Gnome (and possibly a built in application as well, not sure) to view your swap usage.




歡迎光臨 HFL (http://happyfunnyland.com/) Powered by Discuz! 7.2

JinTech Semiconductor Co., Ltd JinTech Semiconductor Co., Ltd - About Us JinTech Semiconductor Co., Ltd - Our Service JinTech Semiconductor Co., Ltd - Expected Quality System Certification JinTech Semiconductor Co., Ltd - Contact Us Our Partners – Sai Fung Electronics Ltd