centos/linux扩容Swap分区

 查看现在的swap容量

[root@node1 ~]# free -h

       total    used    free   shared buff/cache  available

Mem:      15G    3.8G    2.1G     57M    9.6G     11G

Swap:      0B     0B     0B

  

创建一个空文件 大小自己决定,一般swap大小是内存的两倍,我的内存16G,swap给4G也是可以得

[root@node1 ~]# dd if=/dev/zero of=/swapfile bs=1024 count=4096000

4096000+0 records in

4096000+0 records out

4194304000 bytes (4.2 GB) copied, 11.2798 s, 372 MB/s

[root@node1 ~]# ls -lth / | grep swap

-rw-r--r--  1 root  root  4.0G Jul 11 09:48 swapfile

  

 将此分区转换为Swap分区

[root@node1 ~]# mkswap /swapfile 

Setting up swapspace version 1, size = 4095996 KiB

no label, UUID=d40f6aad-6764-4dc4-830f-6f676f5c6fd2

  

 

 将此分区加入Swap

[root@node1 ~]# swapon /swapfile 

swapon: /swapfile: insecure permissions 0644, 0600 suggested.

  

 查看一下

[root@node1 ~]# swapon -s

Filename Type Size Used Priority

/swapfile                file 4095996 0 -1

  

 看下Swap大小

[root@node1 ~]# free -h

       total    used    free   shared buff/cache  available

Mem:      15G    3.8G    165M     57M     11G     11G

Swap:     3.9G     0B    3.9G

  

转载于:https://www.cnblogs.com/LuckWJL/p/9329866.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值