디스크 확인
fdisk -l
...
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
PV(Physical Volume) 확인
pvscan
PV /dev/vda2 VG centos lvm2 [<49.51 GiB / 0 free]
Total: 1 [<49.51 GiB] / in use: 1 [<49.51 GiB] / in no VG: 0 [0 ]
디스크 파티션 작업 시작
fdisk /dev/vdb
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): w
The partition table has been altered!
디스크 파티션 확인
fdiks -l
...
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd03e81c5
Device Boot Start End Blocks Id System
/dev/vdb1 2048 209715199 104856576 83 Linux
새로 만든 파티션을 PV(Physical Volume)로 생성
pvcreate /dev/vdb1
PV(Physical Volume) 확인
pvscan
PV /dev/vda2 VG centos lvm2 [<49.51 GiB / 0 free]
PV /dev/vdb1 lvm2 [<100.00 GiB]
Total: 2 [<149.51 GiB] / in use: 1 [<49.51 GiB] / in no VG: 1 [<100.00 GiB]
생성한 PV를 기존 VG(Volumn Group)에 추가
vgextend centos /dev/vdb1
Volume group "centos" successfully extended
PV(Physical Volume) 확인
pvscan
PV /dev/vda2 VG centos lvm2 [<49.51 GiB / 0 free]
PV /dev/vdb1 VG centos lvm2 [<100.00 GiB / <100.00 GiB free]
Total: 2 [149.50 GiB] / in use: 2 [149.50 GiB] / in no VG: 0 [0 ]
PV(Physical Volume) 상세정보 확인
# 이전 PV
pvdisplay /dev/vda2
--- Physical volume ---
PV Name /dev/vda2
VG Name centos
PV Size 49.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12674
Free PE 0
Allocated PE 12674
# 추가한 PV
pvdisplay /dev/vdb1
--- Physical volume ---
PV Name /dev/vdb1
VG Name centos
PV Size <100.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 25599
Free PE 25599
Allocated PE 0
볼륨그룹 확인
vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 149.50 GiB
PE Size 4.00 MiB
Total PE 38273
Alloc PE / Size 12674 / <49.51 GiB
Free PE / Size 25599 / <100.00 GiB
LV 정보 확인
lvdisplay
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID HiTpqV-Qrx5-iiVC-75yU-2jzU-0r5t-Jmx0mR
LV Write Access read/write
LV Creation host, time localhost, 2018-12-20 18:56:54 +0900
LV Status available
# open 1
LV Size 30.00 GiB
Current LE 7680
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID fSuPrg-ypqk-p0nb-582j-flP5-9gTI-2XqFPA
LV Write Access read/write
LV Creation host, time localhost, 2018-12-20 18:56:55 +0900
LV Status available
# open 1
LV Size <11.51 GiB
Current LE 2946
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
늘리려는 LV(Logical Volumn)을 확장한다.
lvdisplay를 통해 2개가 나왔는데 여기서는 /home에 붙여서 늘릴 예정이다.
- LV path 에서 확인한 값(/dev/centos/home)을 기억해둔다.
- pvdisplay /dev/vdb1 < 를 통해 확인한 Free PE 용량(25599)을 기억해둔다.
이제 아래 명령어를 사용해 확장한다
# lvextend [LV 경로] -l +[용량]
lvextend /dev/centos/home -l +25599
Size of logical volume centos/home changed from 30.00 GiB (7680 extents) to <130.00 GiB (33279 extents).
Logical volume centos/home successfully resized.
파일시스템 리사이징 해주어야 완료된다
그런데 resize2fs 를 사용하면 아래와 같은 에러가 생긴다.
resize2fs /dev/centos/home
resize2fs: Bad magic number in super-block while trying to open /dev/centos/home
Couldn't find valid filesystem superblock.
centos7 의 경우 파일시스템이 xfs 이기 때문에 안된 것.
그래서 다른 명령어를 이용해 갱신한다.
xfs_growfs /dev/centos/home
meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=1966080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7864320 to 34077696
df(Disk FreeSpace) 를 이용해 용량을 확인한다.
# 용량 확장 전
/dev/mapper/centos-home xfs 30G 2.0G 29G 7% /home
# 용량 확장 후
df -h
...
/dev/mapper/centos-home 130G 2.0G 129G 2% /home
...
완료
'공부 > 프로그래밍' 카테고리의 다른 글
[centos7] sudo 사용 시 PATH에 잡히지 않아 실행이 안되는 문제 (0) | 2019.01.16 |
---|---|
[centos7] pinpoint(docker) 서버 구축 및 was(tomcat-docker) 연결 (0) | 2019.01.15 |
[centos7-docker] 용량이 가득 찼을 경우 처리, docker 경로 변경 (2) | 2018.12.25 |
[Centos7-Mariadb] 데이터베이스 통째로 옮기기 (0) | 2018.12.20 |
[centos] 리눅스 파일시스템 HDD, SSD 확인 (0) | 2018.12.11 |
댓글