如何在Linux下增加Swap

本文介绍了Linux系统中Swap空间的相关操作。首先展示了查看系统Swap空间使用情况的方法,接着说明了在合适位置创建swap文件的步骤,最后介绍了激活swap文件的操作,并在激活前后分别查看了系统内存和Swap空间的使用情况。

1.查看系统Swap空间使用

[root@jumper usr]# free
total used free shared buffers cached
Mem: 513980 493640 20340 0 143808 271780
-/+ buffers/cache: 78052 435928
Swap: 1052248 21256 1030992

2.在空间合适处创建swap文件

[root@jumper usr]# mkdir swap
[root@jumper usr]# cd swap
[root@jumper swap]# dd if=/dev/zero of=swapfile bs=1024 count=10000
10000+0 records in
10000+0 records out
[root@jumper swap]# ls -al
total 10024
drwxr-xr-x 2 root root 4096 7月 28 14:58 .
drwxr-xr-x 19 root root 4096 7月 28 14:57 ..
-rw-r--r-- 1 root root 10240000 7月 28 14:58 swapfile


[root@jumper swap]# mkswap swapfile
Setting up swapspace version 1, size = 9996 KiB

3.激活swap文件
[root@jumper swap]# swapon swapfile
[root@jumper swap]# ls -l
total 10016
-rw-r--r-- 1 root root 10240000 7月 28 14:58 swapfile
[root@jumper swap]# free
total used free shared buffers cached
Mem: 513980 505052 8928 0 143900 282288
-/+ buffers/cache: 78864 435116
Swap: 1062240 21256 1040984
[root@jumper swap]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值