티스토리 뷰



1. free -m 명령어로 현재 메모리 상태를 본다.


[root@localhost ~]# free -m

             total       used       free     shared    buffers     cached

Mem:           994        917         76         50          2         44

-/+ buffers/cache:        870        124

Swap:            0          0          0

 > 스왑메모리가 없다.



2. 스왑메모리로 이용할 파일 생성

  (* 일반적으로 메모리 용량의 2배로 설정해 준다.)


메모리가 1G 니까 count 에 2G 가량의 용량을 적어주자.

[root@localhost ~]# dd if=/dev/zero of=/home/swapfile bs=1024 count=2000000

2000000+0 records in

2000000+0 records out

2048000000 bytes (2.0 GB) copied, 19.8498 s, 103 MB/s



3. 스왑 메모리 파일 포맷


[root@localhost ~]# mkswap /home/swapfile

Setting up swapspace version 1, size = 1999996 KiB

no label, UUID=ced5fd29-6893-4134-9239-61d8e2c64016



4. 스왑 공간 활성화


[root@localhost ~]# swapon /home/swapfile

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



5. 재부팅시에도 활성화 되도록 rc.d 에 추가


[root@localhost ~]# vi /etc/rc.d/rc.local


#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#

# In constrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.

touch /var/lock/subsys/local

modprobe ip_conntrack_ftp

swapon /home/swapfile



6. 스왑메모리가 정상적으로 추가되었는지 확인


[root@localhost ~]# free -m

             total       used       free     shared    buffers     cached

Mem:           994        930         64         50          1         56

-/+ buffers/cache:        871        122

Swap:         1953          0       1953


공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함