Siege Lion on the Way (iii) Linux (25)---Linux Memory swap space (swap) construction

Source: Internet
Author: User

Swap is the ability to cope with the lack of physical memory, using the hard disk to temporarily place the information in memory.

For the general host, the physical memory is almost enough, so it will not be used swap, but for the server, when encountering a large number of network requests may be used.

When the swap is used, the host's hard drive lights will blink.

This article describes two ways: 1, set up a swap partition 2, create a virtual memory file.

First, use physical partitions to build swap:

1, the first is the partition:

A, FDISK/DEV/SDA; <== creates a partition based on subsequent prompts.

B, modify the ID of the partition, because Fdisk defaults to the partition's ID as the file system, and the swap ID is 82. Use T to modify under the Fdisk command.

C, call the Partprobe command to update the partition table.

2. Start building swap format:

MKSWAP/DEV/SDA7;

3. Activation and viewing:

SWAPON/DEV/SDA7; <== activation

SWAPOFF/DEF/SDA7; <== off

Swap-s; <== View

Second, the use of files to build swap: (If the above method is not supported when used)

The principle is to use the loop device to mount the way.

1. Use the DD command to create a large empty file:

DD If=/dev/zero of=/tmp/swap bs=1m count=256;

2, Mkswap/tmp/swap;

3, Swapon/tmp/swap;

4, Swapoff/tmp/swap;

Third, swap use on the display:

1, up to 32 swap can be created.

2, in view of the x86_64 maximum memory address space is 64GB, so the total swap is 64GB maximum.

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.