Linux/centos adding a swap partition after loading the system

Source: Internet
Author: User

Swap partition is useful: Swap is when the physical memory is not enough to put the data into the swap, so swap plays a role in the virtual memory, in a sense, it is also an increase in memory space. The general swap partition is set when the system is installed, if you forget to swap partition when installing the system, it is OK, there is a remedy. Let's talk about how to add a swap partition after installing the system.

Scene:
After the installation of the system after the bitter discovery of the swap partition, for the production server, so obviously not, so you need to add a swap partition.


1. First check the swap size
# free
Total used free shared buffers Cached
mem:3922944 158168 3764776 0 6948 37384
-/+ buffers/cache:113836 3809108
swap:0 0 0

This is clearly shown as zero.


2. Create a swap partition with the DD command
# dd If=/dev/zero Of=/doiido/swap bs=1024 count=8388608

Calculation formula for Count: count=size*1024 (SIZE in megabytes)
This creates a/doiido/swap partition file with a size of 8G


3. Format the newly created partition
# Mkswap/main/swap


4. Turn the newly created partition into a swap partition
# Swapon/main/swap

Note: Closing the Swap partition command is: # Swapoff/main/swap


5. Check swap size again
# free
Total used free shared buffers Cached
mem:3922944 158168 3764776 0 6948 37384
-/+ buffers/cache:113836 3809108
swap:8388608 0 8388608


6. Auto-mount swap on boot
# echo "/main/swap swap swap defaults 0 0" >>/etc/fstab



so the swap partition is created

Linux/centos adding a swap partition after loading the system

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.