How Red Hat Linux increases swap space

Source: Internet
Author: User



Follow the steps to explain how Red Hat Linux increases swap space


Method/Step
  1. First step: Make sure there is enough space in the system for swap swap space, I am using KVM, ready to add a swap file to a separate file system, add 2G swap files to/opt/image
  2. Step two: Add the swap file and set its size to 2G, using the following command

    [[email protected] image]# dd If=/dev/zero of=/opt/image/swap bs=1024 count=2048000

    After a while, the following results are returned:

    2048000+0 Records in2048000+0 Records out2097152000 bytes (2.1 GB) copied, 272.867 seconds, 7.7 mb/s

  3. Step Three: Create (set) Swap space, use command Mkswap

    [Email protected] image]# Mkswap/opt/image/swap

    Setting up Swapspace version 1, size = 2097147 KB

  4. Fourth step: Check the size of the existing swap space and use the command free



    [Email protected] image]# free-m


    Total used free shared buffers Cached
    mem:1011 989 21 0 1 875
    -/+ buffers/cache:112 898
    swap:1027 0 1027


    Or check the Meminfo file grep swaptotal/proc/meminfo


  5. Fifth step: Start the newly added 2G swap space, using the command swapon
  6. [Email protected] image]# Swapon/opt/image/swap

  7. Sixth step: Confirm that the newly added 2G swap space is in effect, use the command free



    [[email protected] image]# free-m


    Total used free shared buffers Cached
    mem:1011 995 15 0 4 877
    -/+ buffers/cache:113 897
    swap:3027 0 3027


    Or check the Meminfo file grep swaptotal/proc/meminfo


  8. Seventh Step: Modify the/etc/fstab file so that the newly added 2G swap space automatically takes effect after the system restarts

    Added at the end of the document:/opt/image/swap swap defaults 0 0

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.