Swap分区tip(摘自Redhat官方文档)
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then 1x physical RAM for any amount above 2 GB, but never less than 32 MB.

Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.


Tip
  If your partitioning scheme requires a swap partition that is larger than 2 GB, you should create an additional swap partition. For example, if you need 4 GB of swap, you should create two 2 GB swap partitions. If you have 4 GB of RAM, you should create three 2 GB swap partitions. Red Hat Enterprise Linux supports up to 32 swap files.


For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).



翻译 :当物理内存小于2G时,swap大小为物理内存的2倍。超过2G的部分,swap大小跟物理内存相等。

也即是

x<= 2G的部分, y=2x

x>2G   的部分,  y=x


利用这个法则,2G物理内存需要4G swap,而3G物理内存则需要5G swap。如果你打算添加内存的话,创建一个大些的swap区是很有帮助的。

Tip
如果按照分区计划,你的swap区超过2GB,那么应该创建另外的swap分区。
比如,你需要4GB的swap的分区,应该创建2个2GB的swap分区。

如果有4GB的物理内存,则应该创建3个2GB的swap分区。

Redhat EL支持多达32个swap文件。

分析:2GB的物理内存 需要swap 2x2GB=4GB,
超过2GB的2GB 需要swap 1x2GB=2GB。
总共6G,每个swap分区2G,所以是3个2GB的swap分区

对于超过32G物理内存的,使用小于等于物理内存容量的swap区会更好。
 
增加交換分區的方法: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

1. 查看一下 /etc/fstab 确定目前的分区
2.swapoff /dev/hd**
3.free
看一下是不是停了 .
4.fdisk
删了停掉的 swap 分区
5.
重新用 FDISK 建一个新的 SWAP 分区
6.mkswap /dev/hd**
把新的分区做成 swap
7.swapon /dev/hd**
打开 swap
8.
修改 /etc/fstab
linux中增加swap分区文件的步骤方法:
1、检查当前的分区情况(使用free -m或cat /proc/swaps ):
 [root@db2 root]# free -m
              total       used       free     shared    buffers     cached
 Mem:          1006         84        922          0         11         38
 -/+ buffers/cache:         35        971
 Swap:            0          0          0
 [root@db2 root]#
2、增加交换分区文件及大小:
检查没有swap,下面就需要增加:
判定新交换文件的大小,将大小乘以1024来判定块的大小。例如,大小为64MB的交换文件的块大小为65536,在 shell 提示下以根用户身份键入以下命令,其中的 count 等于想要的块大小。
 [root@db2 root]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000
 1024000+0 records in
 1024000+0 records out
 [root@db2 root]#
使用以下命令来设置交换文件:
 [root@db2 root]# mkswap /home/swap
 Setting up swapspace version 1, size = 1023996 KiB
 [root@db2 root]#
3、启用交换分区文件:
要立即启用交换文件而不是在引导时自动启用,使用以下命令:
 [root@db2 root]# swapon /home/swap
检查增加后的交换情况: 
 [root@db2 root]# free -m
              total       used       free     shared    buffers     cached
 Mem:          1006        994         12          0          4        929
 -/+ buffers/cache:         60        946
 Swap:          999          0        999
 [root@db2 root]#
 
要在引导时启用,编辑 /etc/fstab 文件来包含以下行(/home/swap               swap                    swap    defaults        0 0 ):
 [root@db2 root]# vi /etc/fstab
 LABEL=/                 /                       ext3    defaults        1 1       
 LABEL=/boot             /boot                   ext2    defaults        1 2      /home/swap               swap                    swap    defaults        0 0
        none                    /dev/pts                devpts  gid=5,mode=620  0 0     
        none                    /proc                   proc    defaults        0 0     
        none                    /dev/shm                tmpfs   defaults        0 0     
        LABEL=/usr              /usr                    ext3    defaults        1 2     
        /dev/sda5               swap                    swap    defaults        0 0     
        /dev/cdrom              /mnt/cdrom              iso9660 noauto,owner,kudzu,ro 0 0
        /dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0  
        /home/swap               swap                    swap    defaults        0 0  
系统下次引导时,它就会启用新建的交换文件         
再次检查添加后的情况:
 [root@db2 oracledb]# free -m                                            
                     total       used       free     shared    buffers     cached
        Mem:          1006        979         27          0          6        917
        -/+ buffers/cache:         54        952                                
        Swap:          999          0        999                                
        [root@db2 oracledb]#