歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux下swap分區的設置

Linux下swap分區的設置

日期:2017/2/28 16:04:11   编辑:Linux教程

雖然現在的內存十分的價格低廉,但是合理的規劃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的相關設置

Copyright © Linux教程網 All Rights Reserved