Linux Swap Space

Source: Internet
Author: User

Swap space

The operating system can temporarily swap out some of the memory data to the disk's swap space to free up more memory space, or swap the data into memory from an exchange space.


Linux supports two types of swap space

1. Swap partitions

2. Swap space


The Linux system can have up to 32 swap spaces, with a maximum of 2GB per swap space on a 386-compatible platform.


Recommendations for allocating swap space: 4MB or 8MB, typically 1 to twice times of physical memory


Creation of swap partitions


(1) Preparation: Create a partition/DEV/SDB1 and set its type to the "(Linux Swap)"

(2) format swap partition

Mkswap/dev/sdb1

(3) Enable swap partition

Swapon/dev/sdb1

view swap partition, swap file status : Swapon-s or with free

Deactivate swap partition: SWAPOFF/DEV/SDB1


Creation of swap files


(1) Create a new empty file

DD If=/dev/zero of=/tmp/swapfile bs=1m count=200

(2) format the file as a swap file

Mkswap/tmp/swapfile

(3) Enable swap file

Swapon/tmp/swapfile

(4) If you want to activate this swap file automatically when the system starts, add the following line to the/etc/fstab

/tmp/swapfile Swap swap defaults 0 0

Deactivate swap file: Swapoff/tmp/swapfile


This article is from the "IT" blog, so be sure to keep this source http://wang119.blog.51cto.com/9428009/1795374

Linux Swap Space

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.