Centos7修改swap大小

查看swap 大小

一般的swap大小是实体内存的1-2倍,本例修改为内存的1.5倍。

[root@services swap]# free
total used free shared buff/cache available
Mem: 1882356 92720 1116504 492 673132 1624656
Swap: 0 0 0

可以看到此服务器没有设置 swap 大小,这里我们为了安装oracle12c,将swap调整为3G

设置swap文件大小

创建/usr/swap文件,并进入该文件

[root@services ~]# mkdir /usr/swap && cd /usr/swap

创建3g大小文件

[root@services swap]# dd if=/dev/zero of=swapfile bs=1G count=3
3+0 records in
3+0 records out
3221225472 bytes (3.2 GB) copied, 30.0177 s, 107 MB/s

查看文件大小

[root@services swap]# ll
total 3145732
-rw-r–r-- 1 root root 3221225472 May 14 21:39 swapfile

修改为swap文件格式

[root@services swap]# mkswap /usr/swap/swapfile
Setting up swapspace version 1, size = 3145724 KiB
no label, UUID=1cc9cb0c-4cc7-4c2d-981c-11da20dd9014

设置永久生效

删除原来swap类型行数据,新增一行/usr/swap/swapfile swap swap defaults 0 0

[root@services swap]# vi /etc/fstab
/dev/mapper/centos-root / xfs defaults 0 0
UUID=b8febb87-f699-469b-8ba8-425f54aa99d0 /boot xfs defaults 0 0
#/dev/mapper/centos-swap swap swap defaults 0 0
/usr/swap/swapfile swap swap defaults 0 0
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhipengit

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值