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

  

posted @ 2018-07-18 16:20  Chuyio  阅读(2445)  评论(0编辑  收藏  举报