In linux, how to set swap partition is generally only available in xen VPS, but openvz does not. Swap partitions can increase a certain amount of memory usage, but the most important role of adding swap partitions is to prevent the sudden increase of website traffic, resulting in insufficient memory allocation by the system and a crash. If your VPS has been using swap for a long time, we recommend that you check the program or VPS, or upgrade the VPS with larger memory, because swap is used to switch the shard, this reduces server performance and slows down access. Next we will look at how to add swap partitions. 1. log on to SSH with the root permission and type the following command to create a 1024 MB swap file (512*524288 MB = ). www.2cto.com dd if =/dev/zero of =/swapfile1 bs = 1024 count = 5242882, create a Linux swap file mkswap/swapfile13, activate immediately/swapfile1 swap file swapon/swapfile14, set the system from activate the swap file. Edit the/etc/fstab file and add the following second line of code. Vi/etc/fstab/swapfile1 swap defaults 0 05. restart the system and use free-m to view the swap size. # Vi/etc/fstab UUID = b45eed4a-b319-43fa-9d03-200c558b5d84/ext4 defaults 1 1 UUID = actuator/boot ext4 defaults 1 2/dev/sdb5 swap defaults 0 0 UUID = bddbfd46-378f-4583-930f-554f9c6f4ab6 swap defaults 0 0 tmpfs/dev/shm tmpfs defaults 0 0 devpts/dev/pts devpts gid = 5, mode = 620 0 0 sysfs/sys sysfs defaults 0 0 proc/proc defaults 0 0