How to create a swap partition in CentOS 7

Source: Internet
Author: User
Tags centos

The swap partition is created to make up for the lack of physical memory, that is, the concept of virtual memory. Part of the hard disk is divided into virtual memory, but the larger the space, the better, the speed of the hard disk is much lower than that of the memory. If the hard disk is not set properly, the speed of the system is slowed down.

By default, Alibaba Cloud hosts do not have swap partitions. You can run the free command to view them:

This is the screenshot after swap partition is created on CentOS 7. The following describes how to create a swap partition on CentOS 7:

① Use the dd command to create a swap partition


Dd if =/dev/zero of =/home/swap bs = 1024 count = 1048576

The value of count is: size (MB) * 1024. Here I set 1 GB virtual memory, that is, count = 1024000.

② Format swap partitions


Mkswap/home/swap

③ Set the formatted file partition to a swap partition.

Swapon/home/swap

(Run the [root @ localhost Desktop] # swapoff/home/SWAP command to disable swap Partitioning)

At this point, the swap partition has been created. Run the free command to view the details. You can see that there is an additional Mount partition.

④ Automatically mount swap partitions

Vi/etc/fstab

Add

/Home/swap default 0 0

Related Article

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.