How to Set swap partitions in linux

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.