Swap partition for Linux

Source: Internet
Author: User

Chen Kozhan

========================

Operating environment: Ubuntu Server 14.04 LTS

=========================

Brief introduction

1. What is a swap partition and what is the role of

2. How to set the swap partition

===================================================

1. What is a swap partition and what is the role?

Swap partition, swap partition, that is, when your physical memory is not enough, the space portion of the hard disk is freed up for the current program to run. For a program that is running for a long time without any action, these programs are temporarily stored in the freed space, swap partition, and then restore the data from the swap partition to memory when the program is again manipulated.

2. How to set the swap partition

1. First, we need to know the details of the swap partition before it is easy to set up:

Type the command: #free

Note: The default unit is K,-M, which means the unit is M,-G and the unit is G


2. View swap space files and partition information

# swapon-s or # Cat/proc/swaps

Note: filename-file name, partition-partition


3. increase swap space-increase swap space by creating swap files

1). Use root permissions

Su Root

2). Create a large file

# dd If=/dev/zero of=/swapfile bs=1024 count=500

Note: Create a swap file of size 500M, if= input file or device name, of= output file or device name,bs = bytes Simultaneously set the number of bytes read/write buffer (equal to set IBS and OBS) parameters, we can go to Baidu search DD command details


3). Convert/swapfile files to swap files

# Mkswap/swapfile

4). Activate/swapfile swap file now

# Swapon/swapfile

4). Set the system to automatically activate the/swapfile swap file

#vi/etc/fstab

Append write:/swapfile swap swap defaults 0 0

5). Execute free or cat/proc/swaps to see if the swap partition is enabled


4. Delete Swap space

1). Turn off swap partitions

#swapoff/swapfile

Parameters:
-A turns off all devices in the/etc/fstab file that are set to swap
-V Show More information


2). from /etc/fstab The code that was appended before the deletion, then delete the file, you can





Swap partition for Linux

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.