Linux expands swap space

Source: Internet
Author: User


Linux expands swap space

There are two solutions: one is to create a new swap partition, and the other is to create a swap file.
Create a swap file
If all your hard disk space has been allocated to other partitions and there is no extra budget to purchase a new hard disk, we can use the swap file to increase the virtual swap space, however, the execution performance is worse than the actual swap partition.
To create a swap file, run the dd command to add a MB swap file:
# Dd if =/dev/zero of =/100M. swap bs = 1 M count = 100
Run the mkswap command to format the myswap file into the s file system. The system can use it, switch to the/directory, and run the following command:
# Change the file type of fdisk/100m. swap to 82 linux swap.
# Mkswap/100m. swap
Setting up swapspace version 1, size = 104853 kB
# Swapon-s view the current swap information
Filename Type Size Used Priority
/Dev/mapper/VolGroup00-LogVol01 partition 524280 0-1
# Swapon-a/100m. swap-p-2 activate the partition and set its priority
# Swapon-s view the modified swap space
Filename Type Size Used Priority
/Dev/mapper/VolGroup00-LogVol01 partition 524280 0-1
/100m. swap file 102392 0-2
# Free
Total used free shared buffers cached
Mem: 255840 56164 199676 0 8128 26640
-/+ Buffers/cache: 21396 234444
Swap: 626672 0 626672
# Swapoff Cancel activation of swap space, swapon-a/dev/sda2-p-10 activate and set priority



Author ehlopxp

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.