centos7 关闭swap分区

目录

1. 查看swap分区信息

2. 关闭swap分区

 

1. 查看swap分区信息

通过free -h 命令查看
[root@k8s-master-02 ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 131M 1.4G 8.9M 212M 1.5G
Swap: 2.0G 0B 2.0G

 

2. 关闭swap分区

2.1 临时关闭( swapoff -a )

[root@k8s-master-02 ~]# swapoff -a && sysctl -w vm.swappiness=0
vm.swappiness = 0
[root@k8s-master-02 ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 130M 1.4G 8.9M 212M 1.5G
Swap: 0B 0B 0B
[root@k8s-master-02 ~]#

2.2 永久关闭

1. swapoff -a临时关闭

2. 修改 /etc/fstab

[root@k8s-master-02 ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Mar 16 07:02:59 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=b0ccc2ce-e243-4fba-b70a-f73250c006f0 / xfs defaults 0 0
UUID=9f7a36a9-28dc-48dc-b070-6b229daffab2 /boot xfs defaults 0 0
#UUID=752a1d2f-0a88-4e62-aa4c-49fc3c57a8e9 swap swap defaults 0 0
[root@k8s-master-02 ~]#

3. vim /etc/sysctl.conf # 永久生效
修改 vm.swappiness 的修改为 0
vm.swappiness=0
sysctl -p # 使配置生效,如果不生效,只能重启


[root@k8s-master-02 ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 128M 1.4G 8.8M 245M 1.5G
Swap: 0B 0B 0B

posted @   GaoYanbing  阅读(310)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2020-11-13 LDAP入门
点击右上角即可分享
微信分享提示