In the batch set up the environment, encountered after the completion of the environment found swap forget the situation, later Baidu, found the following method, the online may exist a lot of corresponding Post said this thing is relatively simple, the following is the results of their own practice, share to everyone.
1. View existing memory and swap
[Email protected] tmp]# free-m total used free shared buffers cachedmem: 7869 164 7705 0 7 -/+ buffers/cache: 108 7760Swap: 0 0 0
2. Create a 8G file with the DD command (8g=1024*1024*8=8388608)
if=/dev/xvda of=/var/swapfile bs=1024x768 count=83886088388608+0 in 8388608+0out8589934592 bytes (8.6318.562 27.0 MB/
3. Create it as a Linux swap virtual swap file
[[email protected] ~]# Mkswap/var//var/swapfile:warning:don't Erase Bootbits sectorson whole disk. Use-18388604 kibno label, UUID=0a4afee0-20da-40d0-81a1-~]# swapon/ var/swapfile
4. You can use FREE-M to see the swap size and use swapon-s to view swap status
[Email protected] ~]# free-m total used free shared buffers Cachedmem:7869 167 7702 0 8 --/+ Buffers/cache: the 7758Swap:8191 0 8191[[Email protected]~]# Swapon-sfilename Type Size used priority/var/swapfile file8388600 0-1[[Email protected]~]#
5. Set the system startup to activate the virtual Exchange file automatically
[Email protected] ~]# vi/etc//var/swapfile swap defaults 0 0
Linux Increase swap partition