添加一个8G 的swap
cd / dd if=/dev/zero of=/swapfile bs=1k count=8192000 mkswap /swapfile chmod 0600 /swapfile swapon /swapfile echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
详情见下面
[root@lab01 /]# cd / [root@lab01 /]# dd if=/dev/zero of=/swapfile bs=1k count=2048000 2048000+0 records in 2048000+0 records out 2097152000 bytes (2.1 GB) copied, 14.1909 s, 148 MB/s [root@lab01 /]# free -m total used free shared buff/cache available Mem: 1838 70 67 0 1699 1599 Swap: 0 0 0 [root@lab01 /]# mkswap /swapfile Setting up swapspace version 1, size = 2047996 KiB no label, UUID=0cc4aeeb-a55d-430e-8671-297f33bde299 [root@lab01 /]# chmod 0600 /swapfile [root@lab01 /]# swapon /swapfile [root@lab01 /]# free -m total used free shared buff/cache available Mem: 1838 72 81 0 1683 1597 Swap: 1999 0 1999 [root@lab01 /]# echo "/swapfile swap swap defaults 0 0" >> /etc/fstab [root@lab01 /]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Jul 11 02:52:01 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=1114fe9e-2309-4580-b183-d778e6d97397 / ext4 defaults 1 1 /swapfile swap swap defaults 0 0