Cause: The swap area is too small and the system freezes.
Solution: Increase the size of the swap area
1. Solution
1. Check the size of the swap area:
free -m
2. Enter the root user (very important, it will be troublesome not to continue)
sudo su - root
3. Create a directory:
mkdir /swap
4. Enter the catalog
cd /swqp
5. Enter the following command:
dd if=/dev/zero of=swapfile bs=1024 count=10290000
a.可以看到如下内容:
记录了1029000+0 的读入
记录了1029000+0 的写出
1053696000字节(1.1 GB)已复制,69.0168 秒,15.3 MB/秒
b.可以用 < ls -lh > 可以看到一个文件。
-rw-r--r-- 1 root root 1005M 2010-01-02 14:35 swapfile
6. Configuration
mkswap swapfile
7. Mount the swap area:
swapon swapfile
8. Check the size of the swap area
free -m
Possible errors
1. Insecure permissions 0644, 0600 is recommended (modify permissions)
chmod 0600 /swap/swapfile
2. The device or resource is busy (activate the swap file)
swapoff /swap/swapfile
swapon /swap/swapfile
3. The swap area restores to the default after booting
命令:sudo vim /etc/fstab
添加: /swap/swapfile /swap swap defaults 0 0
保存::wq