Swap分区,即交换区
一、查看已有swap空间
[root@test ~]# free -m
Mem:
-/+ buffers/cache:
Swap:
二、新增swap分区空间
1、使用dd创建swapfile,bs单位bytes,也可以手动指定单位为M或者G,count为计数,例子为增加1M*1024=1G空间
[root@test swap]#pwd
/swap
[root@test swap]# dd if=/dev/zero of=swapfile bs=1M
count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.27273 seconds, 472
MB/s
[root@test swap]# ll
total 1049604
-rw-r--r-- 1 root root 1073741824 Sep 16 20:48 swapfile
2、mkswap创建交换文件
[root@test swap]# mkswap swapfile
Setting up swapspace version 1, size = 1073737 kB
3、swapon激活
[root@test swap]# swapon swapfile
4、查看增加后swap空间
[root@test swap]# free -m
Mem:
-/+ buffers/cache:
Swap:
5、开机启动
vim /etc/fstab 添加
/swap/swapfile
6、去掉增加swap
# 查看
[root@test swap]# free -m
# 停用
[root@test swap]# swapoff swapfile
# 删除
[root@test swap]# rm swapfile -rf
# 确定
[root@test swap]# free
-m
# 删除随即启动swap
[root@test
swap]#
扩展阅读(来自百度百科):
|
|