Swap File 생성하기
1.현재의 Swap 정보 확인
[root@testora /]# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 4194300 1576020 -1 [root@testora /]# free -h total used free shared buffers cached Mem: 2.9G 2.7G 190M 715M 216M 1.0G -/+ buffers/cache: 1.4G 1.4G Swap: 4.0G 1.5G 2.5G
위 정보와 같이 Swap 공간이 모자르지는 않지만 테스트를 위해 Swap File을 추가 해 보기로 한다.
2.Swap File로 사용할 File을 생성
[root@testora /]# ls -al /imsi_swapfile ls: cannot access /imsi_swapfile: 그런 파일이나 디렉터리가 없습니다 [root@testora /]# dd if=/dev/zero of=/imsi_swapfile bs=1M count=500 500+0 records in 500+0 records out 524288000 bytes (524 MB) copied, 0.826755 s, 634 MB/s [root@testora /]# ls -lh /imsi_swapfile -rw-r--r--. 1 root root 500M 2019-04-15 11:07 /imsi_swapfile
3.적절한 파일 권한으로 변경
[root@testora /]# chmod 600 /imsi_swapfile [root@testora /]# ls -lh /imsi_swapfile -rw-------. 1 root root 500M 2019-04-15 11:07 /imsi_swapfile
4.Swap으로 등록
[root@testora /]# mkswap /imsi_swapfile mkswap: /imsi_swapfile: warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 511996 KiB no label, UUID=8c632ca0-3a21-425f-8aa6-79c0a90e3db5 [root@testora /]# swapon /imsi_swapfile
재부팅 후에도 추가한 Swap 공간이 적용되어 사용되기를 원한다면 /ect/fstab 파일에 아래 항목을 추가해야 한다.
/imsi_swapfile swap swap defaults 0 0
5.추가된 Swap 정보 확인
[root@testora /]# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 4194300 1576000 -1 /imsi_swapfile file 511996 0 -2 [root@testora /]# free -h total used free shared buffers cached Mem: 2.9G 2.8G 100M 715M 90M 1.3G -/+ buffers/cache: 1.4G 1.4G Swap: 4.5G 1.5G 3.0G [root@testora /]#
위와 같이 추가된 정보를 확인할 수 있다.
6.추가적인 정보
swappiness 설정이 존재한다. 시스템이 Swap 사용에 대한 선호도를 1-100 까지의 값으로 설정할 수 있다.
작은 값일수록 커널이 Swap 사용을 줄이려고 하며 큰 값일수록 커널이 Swap을 적극적으로 사용할려고 하는 경향이 커진다.
[root@testora /]# cat /proc/sys/vm/swappiness 60 [root@testora /]# sysctl vm.swappiness=50 vm.swappiness = 50 [root@testora /]# cat /proc/sys/vm/swappiness 50
이 파라미터 값을 재부팅 후에도 적용하고 싶다면 /etc/sysctl.conf 파일에 아래 항목을 추가한다.
vm.swappiness=50
# swappiness value vm.swappiness=50 "/etc/sysctl.conf" 52L, 1420C written
3.Swap File 삭제
[root@testora /]# swapoff -v /imsi_swapfile swapoff on /imsi_swapfile [root@testora /]# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 4194300 1575988 -1 [root@testora /]# free -h total used free shared buffers cached Mem: 2.9G 2.8G 98M 715M 91M 1.3G -/+ buffers/cache: 1.4G 1.4G Swap: 4.0G 1.5G 2.5G [root@testora /]# ls -al /imsi_swapfile -rw-------. 1 root root 524288000 2019-04-15 11:09 /imsi_swapfile [root@testora /]# rm /imsi_swapfile rm: remove 일반 파일 `/imsi_swapfile'? y [root@testora /]# ls -al /imsi_swapfile ls: cannot access /imsi_swapfile: 그런 파일이나 디렉터리가 없습니다 [root@testora /]#
/etc/fstab에 적용해 놓았다면 해당 항목을 제거한다.
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
26 | HP-UX Glance adviser를 활용하여 모니터링 데이터 수집 | 명품관 | 2016.04.08 | 9542 |
25 | RAC SCAN 사용을 위한 DNS 서버 설정하기 | 명품관 | 2020.11.10 | 9237 |
24 | strace 사용법 | 명품관 | 2016.02.18 | 8321 |
23 | nmon 사용법 | 명품관 | 2016.02.05 | 7812 |
22 | sudo 사용시 is not in the sudoers file. This incident will be reported 에러 해결법 | 명품관 | 2016.02.19 | 3413 |
21 | Oracle Linux 8.2 버전 chrony 설정하기 | 명품관 | 2020.09.17 | 2418 |
20 | iscsi 서버/클라이언트 설정하기(with targetcli) | 명품관 | 2020.11.14 | 2242 |
19 | 실시간으로 TCP와 UDP 포트를 감시하는 방법 | 명품관 | 2020.02.05 | 2230 |
18 | 59 Linux Networking commands and scripts | 명품관 | 2019.11.18 | 1592 |
17 | Memory Usage 확인용 스크립트 [2] | 명품관 | 2019.04.15 | 1423 |
16 | [7.x] hostname 변경하는 hostnamectl 사용법 [1] | 우뽕 | 2020.02.05 | 1002 |
15 | 리눅스 Free 메모리의 이해 | 명품관 | 2018.08.08 | 989 |
14 | Linux에서 LVM 사용 | 명품관 | 2020.11.10 | 852 |
13 | top logging script | Talros | 2020.01.17 | 832 |
12 | find 사용하기 | 명품관 | 2016.03.04 | 738 |
11 | Alias 사용 | 명품관 | 2021.03.03 | 674 |
» | Swap File 생성하기 | 명품관 | 2019.04.15 | 664 |
9 | vi 에디터 환경 설정 | 명품관 | 2016.02.02 | 643 |
8 | bpytop 모니터링 툴 | 명품관 | 2021.01.18 | 629 |
7 | Installing RedHat Enterprise Linux 8.0 with screenshots | 명품관 | 2019.09.26 | 546 |