虽然现在的内存十分的价格低廉,但是合理的规划swap分区可以很大程度的提高系统运行的稳定性。下边Linux下介绍swap分区的相关设置!
[root@localhost ~]# dd if=/dev/zero of=/data/swapfile bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.143459 seconds, 73.1 MB/s
[root@localhost ~]# mkswap /data/swapfile
Setting up swapspace version 1, size = 10481 kB
[root@localhost ~]# free
total used free shared buffers cached
Mem: 444416 294176 150240 0 18432 198928
-/+ buffers/cache: 76816 367600
Swap: 1048568 0 1048568
[root@localhost ~]# swapon /data/swapfile
[root@localhost ~]# free
total used free shared buffers cached
Mem: 444416 294176 150240 0 18448 198928
-/+ buffers/cache: 76800 367616
Swap: 1058800 0 1058800
[root@localhost ~]# swapoff /data/swapfile
[root@localhost ~]# free
total used free shared buffers cached
Mem: 444416 294176 150240 0 18472 198928
-/+ buffers/cache: 76776 367640
Swap: 1048568 0 1048568
这就是swap的相关操作,不过想要系统重启之后依然存在需要修改/etc/fastab添加以下的那句话
/data/swapfile none swap sw 0 0
总结:此次操作是为了了解swap的相关设置