#需求
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