본문 바로가기
IT/LINUX

[LINUX][RHEL7] SWAP 추가하기

by 양눈 2016. 12. 17.
반응형

[LINUX][RHEL7] SWAP 추가하기

 

1. 파티션생성(gdisk 사용)

# gdisk /dev/sdd
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-8388574, default = 2048) or {+-}size{KMGTP}: <enter>
Last sector (2048-8388574, default = 8388574) or {+-}size{KMGTP}: 1G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): L
8200 Linux swap 8300 Linux filesystem 8301 Linux reserved
8e00 Linux LVM a500 FreeBSD disklabel a501 FreeBSD boot
.....
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-8388574, default = 2099200) or {+-}size{KMGTP}: <enter>
Last sector (2099200-8388574, default = 8388574) or {+-}size{KMGTP}: +1G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'

Command (? for help): p

Number Start (sector) End (sector) Size Code Name
1 2048 2097152 1023.0 MiB 8200 Linux swap
2 2099200 4196351 1024.0 MiB 8200 Linux swap

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.

[TEST-root] rh70:/# partprobe /dev/sdd

[TEST-root] rh70:/# gdisk -l /dev/sdd
........
Number Start (sector) End (sector) Size Code Name
1 2048 2097152 1023.0 MiB 8200 Linux swap
2 2099200 4196351 1024.0 MiB 8200 Linux swap
[TEST-root] rh70:/#

# ll /dev/sdd*
brw-rw----. 1 root disk 8, 48 3
4 14:58 /dev/sdd
brw-rw----. 1 root disk 8, 49 3
4 14:58 /dev/sdd1
brw-rw----. 1 root disk 8, 50 3
4 14:58 /dev/sdd2

2.
스왑초기화(mkswap)
# mkswap /dev/sdd1

Setting up swapspace version 1, size = 1047548 KiB
no label, UUID=6f27a83b-c618-4cde-99ce-97849bce55ee

# mkswap /dev/sdd2
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=4836c1d4-4e3d-42b4-9db5-a53c8b6c4512

3.
마운트 지점 추가(fstab)
1) uuid 확인

#blkid | grep swap
/dev/mapper/rhel-swap: UUID="d571c99b-90db-45da-85f7-2ca7f81f89c4" TYPE="swap"
/dev/sdd1: UUID="6f27a83b-c618-4cde-99ce-97849bce55ee" TYPE="swap" PARTLABEL="Linux swap" PARTUUID="2b05bb6b-8247-462b-81b2-0e92872e294f"
/dev/sdd2: UUID="4836c1d4-4e3d-42b4-9db5-a53c8b6c4512" TYPE="swap" PARTLABEL="Linux swap" PARTUUID="a3fb2f21-4daf-4975-9249-95ba01d6f25f"

2) /etc/fstab
추가
# vim /etc/fstab
UUID="6f27a83b-c618-4cde-99ce-97849bce55ee" swap swap default 0 0
UUID="4836c1d4-4e3d-42b4-9db5-a53c8b6c4512" swap swap pri=1 0 0

디바이스 마운트포인트 타입 옵션 체크옵션2

4. 스왑활성화
# swapon -a

5. 스왑확인
# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 4079612 0 -1
/dev/sdd1 partition 1047548 0 -2
/dev/sdd2 partition 1048572 0
1

# free
total used free shared buffers cached
Mem: 3883788 1865480 2018308 18256 11760 957444
-/+ buffers/cache: 896276 2987512
Swap: 6175732 0 6175732

반응형

댓글