Add Delete swap space under Linux

Source: Internet
Author: User

#需求

Need to add 10G swap space due to tight system memory resources


#创建存放swap文件的目录

[Email protected] ~]# Mkdir/swap

#创建一个10G空文件

[[email protected] ~]# dd If=/dev/zero of=/swap/swap bs=1024m count=1010+0 Records in10+0 records out10737418240 bytes (11 GB) copied, 20.745 s, 518 MB/s


#格式化为交换空间

[Email protected] ~]# Mkswap/swap/swapmkswap:/swap/swap:warning:don ' t erase bootbits sectors on whole disk. Use-f to force. Setting up Swapspace version 1, size = 10485756 kibno label, uuid=844fb94b-c5e5-4d55-a091-c310b9e5e289


#查看系统内存

[[email protected]_37_0_centos ryzc]# free -m              total        used       free     shared     buffers     cachedMem:          24028      22842       1185           0        149        3530-/+ buffers/cache:      19162        4866Swap:         2047        1127        920 


#添加交换空间

[Email protected] ~]# Swapon/swap/swap


#再次查看系统内存

[Email protected] ~]# free-m total used free shared buffers cachedmem:24028 22888 1139 0 3563-/+ buffers/cache:19174 4853swap:12287 112 5 11162


#放到开机启动

[Email protected] ~]# tail-1/etc/rc.local Swapon/swap/swap


#删除swap

[Email protected] ~]# Swapoff/swap/swap [[email protected] ~]# Rm-rf/swap/swap

This article is from the "Wsyht blog" blog, make sure to keep this source http://wsyht2015.blog.51cto.com/9014030/1792692

Add Delete swap space under Linux

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.