Increase the size of swap space in centos

Source: Internet
Author: User

I want to install oracle10g in the Virtual Machine and find that the default swap space does not meet the minimum requirement. Because the physical memory I allocate is 1 GB, 2 GB swap space is required as required, by default, only 1 GB of swap space is available. To add a swap space, follow these steps:

Step 1: make sure that there is sufficient space in the system for swap. I am using KVM and want to add a swap file to an independent file system, add 2 GB swap file to/opt/image
Step 2: add the swap file and set its size to 2 GB. Run the following command:

[Root @ sense image] # dd if =/dev/zero of =/opt/image/swap bs = 1024 count = 2048000

After a period of time, the following results are returned:
2048000 + 0 records in
2048000 + 0 records out
2097152000 bytes (2.1 GB) copied, 272.867 seconds, 7.7 MB/s

Step 3: Create (SET) the swap space and run the mkswap command.

[Root @ sense image] # mkswap/opt/image/swap
Setting up swapspace version 1, size = 2097147 kB

Step 4: Check the size of the existing swap space and run the free command.

[Root @ sense 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

Step 5: Start the newly added 2 GB swap space and run the swapon command

[Root @ sense image] # swapon/opt/image/swap

Step 6: confirm that the new 2G swap space has taken effect. Run the free command.

[[Root @ sense 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

Step 7: Modify the/etc/fstab file so that the newly added 2G swap space will automatically take effect after the system restarts.

Add at the end of the file:
/Opt/image/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.