Linux添加Swap

给Linux添加Swap

# 添加前

[email protected]:~# free -mt
             total       used       free     shared    buffers     cached
Mem:         32174        833      31341          0         30        630
-/+ buffers/cache:        172      32002
Swap:            0          0          0
Total:       32174        833      31341

# 添加

dd if=/dev/zero of=/var/swapfile0 bs=1024M count=4
mkswap /var/swapfile0
swapon /var/swapfile0
vi /etc/fstab
/var/swapfile0  none swap sw 0 0
mount -a

# 添加后

[email protected]:~# free -mt
             total       used       free     shared    buffers     cached
Mem:          3951       2396       1555         81         22       2036
-/+ buffers/cache:        337       3614
Swap:         4095          0       4095
Total:        8047       2396       5651
*****
Written by ysicing on 07 July 2017