Red Flag asianux Server 3 System Management: Swap Space

Source: Internet
Author: User
Keywords Swap space Asianux
Tags activate aliyun create delete disk exchange file files

Swap space is a part of the system that is partitioned from the hard disk, and when physical memory (RAM) is filled, inactive pages in memory are moved to swap space. The size of the swap space is generally set to 1~2 times the physical RAM, but not more than http://www.aliyun.com/zixun/aggregation/9392.html ">2048MB."

Swap space can be one or more dedicated swap partitions (recommended), or one or more swap files, or a combination of both.

A swap partition was created when the Red Flag asianux Server 3 system was installed, which is used to support swap space for virtual memory.

The Red Flag asianux Server 3 system allows the user to resize the swap space after the installation completes.

2.4.1 Using swap partitions

Create and enable swap partitions

The Red Flag asianux Server 3 system allows you to include multiple swap partitions, each up to 124M. These swap partitions can be created and activated at any time as needed, as follows:

1 use parted or Fdisk to divide a partition and give the appropriate size.

2 Format the partition and check for bad blocks;

# mkswap-c/DEV/HDA4

Replace/dev/hda4 with the actual partition device name, which does not indicate the partition size, and the system detects it automatically.

3 Activate the swap partition using the following command:

# SWAPON/DEV/HDA4

4 If you want to activate this swap partition automatically at system startup, you should include the following line in Fstab:

/DEV/HDA4 Swap Defaults 0 0

After you add the swap partition and enable it, use the cat/proc/swaps or free command to see if the swap partition is successfully enabled.

Turn off swap partitions

To turn off the swap partition, you can perform the following command:

# SWAPOFF/DEV/HDA4

Remove Swap partition

1 Confirm that the swap partition that will be deleted has been closed;

2 delete the corresponding line in the Fstab file;

3 Use the parted or FDISK command to delete the corresponding partition.

2.4.2 Using swap files

Create and enable swap files

A swap file is a remedy for temporarily needing to swap space. You can have up to 8 swap files in the system, each with a maximum of 16M, and the following steps to create an interchange file.

1 Create a file with the size you want

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

This command will physically create a swap file/swapfile, each file block size of 1024 bytes, a total of 8192 pieces, the file size is 8M (because the interchange file must be contiguous, so the CP command can not create the Exchange file).

2) Create an interchange file

# Mkswap/swapfile

3 Activates the Exchange file, and the activated file is immediately enabled.

# Swapon/swapfile

4 If you want to activate this Exchange file automatically at system startup, you should include the following line in Fstab:

/swapfile Swap Defaults 0 0

After you add the swap file and enable it, use the cat/proc/swaps or free command to see if the swap file is successfully enabled.

Close swap file

After you use the swap file, you can close it.

# Swapoff/swapfile

Delete swap file

# Rm/swapfile

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.