[CENTOS] Create SWAP for CentOS7
2016-05-28 本文已影响0人
AlfredL
Check the System for Swap Information
We can see if the system has any configured swap by using swapon, a general-purpose swap utility. With the -s
flag, swapon will display a summary of swap usage and availability on our storage device:
swapon -s
If nothing is returned by the command, then the summary was empty and no swap file exists.
Check Available Storage Space
df -h
Create a Swap File
sudo fallocate -l 4G /swapfile
ls -lh /swapfile
Enable a Swap File
sudo mkswap /swapfile
sudo swapon /swapfile
Make the Swap File Permanent
sudo nano /etc/fstab
At the bottom of the file, you need to add a line that will tell the operating system to automatically use the swap file that you created:
/swapfile swap swap sw 0 0