본문 바로가기

리눅스

[리눅스] CentOS swap 메모리 비활성화(swap 영역 해제)

728x90

CentOS swap 메모리 비활성화(swap 영역 해제)

swap 활성화되어 있는 상태

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.9G        268M        3.4G        8.9M        232M        3.4G
Swap:          3.9G          0B        3.9G
$ swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       4063228 0       -2

swap 메모리 비활성화

$ swapoff -a

#또는

$ blkid
/dev/sda1: UUID="b9d3aecd-6fef-44f9-8c28-e3ffc7805b1a" TYPE="xfs" 
/dev/sda2: UUID="IWcQND-I5UU-beZS-Tdlu-vufA-4NFr-Sgum4c" TYPE="LVM2_member" 
/dev/mapper/centos-root: UUID="2291aa93-a0d8-455c-8e63-d6a90ab970e5" TYPE="xfs" 
/dev/mapper/centos-swap: UUID="9f9681c5-fd06-4ba8-bf09-b7c092cdc892" TYPE="swap"

$ swapoff /dev/mapper/centos-swap

swap 메모리 상태 확인

#출력값이 없으면 swap 메모리가 비활성화된 상태입니다. 
$ swapon -s
#"Swap:            0B          0B          0B" 
#위와 같이 출력되면 swap 메모리가 비활성화된 상태입니다.
$ free -h   
              total        used        free      shared  buff/cache   available
Mem:           3.9G        266M        3.4G        8.8M        232M        3.4G
Swap:            0B          0B          0B

fstab(/etc/fstab) 편집

시스템 재부팅을 대비하여 fstab(/etc/fstab)도 편집합니다.

'/dev/mapper/centos-swap swap swap defaults 0 0' 주석 처리

$ vim /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Thu Oct 28 10:45:25 2021
#
# 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
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=0a5b6a47-8bc8-4b14-ac5a-ac8dbdb4c8ef /boot                   xfs     defaults        0 0
#/dev/mapper/centos-swap swap                    swap    defaults        0 0
728x90