728x90
가상머신에서 OS 운영 하다보면 disk 용량이 부족한 경우가 발생 한다.
LVM 파티션으로 설치 했다면 디스크 추가 없이 용량 증설이 가능하다.
30GB disk를 50GB 증설 완료
- 기존 root 파티션에는 26GB 잡혀 있다.
[root@localhost ~]# fdisk -l
Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000b3de1
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 2099199 1048576 83 Linux
/dev/xvda2 2099200 62914559 30407680 8e Linux LVM
Disk /dev/mapper/centos-root: 27.9 GB, 27913093120 bytes, 54517760 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
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 9.6M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 26G 7.7G 19G 30% /
/dev/xvda1 xfs 1014M 202M 813M 20% /boot
tmpfs tmpfs 781M 28K 781M 1% /run/user/1000
tmpfs tmpfs 781M 0 781M 0% /run/user/0
- 파티션 생성
[root@localhost ~]# fdisk /dev/xvda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3): 3
First sector (62914560-104857599, default 62914560):
Using default value 62914560
Last sector, +sectors or +size{K,M,G} (62914560-104857599, default 104857599):
Using default value 104857599
Partition 3 of type Linux and of size 20 GiB is set
- 생성 된 파티션 확인
Command (m for help): p
Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000b3de1
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 2099199 1048576 83 Linux
/dev/xvda2 2099200 62914559 30407680 8e Linux LVM
/dev/xvda3 62914560 104857599 20971520 83 Linux # 파티션 생성 확인
- 파티션 유형 변경
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w
- 볼륨 생성 확인
[root@localhost ~]# fdisk -l
Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000b3de1
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 2099199 1048576 83 Linux
/dev/xvda2 2099200 62914559 30407680 8e Linux LVM
/dev/xvda3 62914560 104857599 20971520 8e Linux LVM # LVM 파티션 생성 확인
Disk /dev/mapper/centos-root: 27.9 GB, 27913093120 bytes, 54517760 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 /dev/mapper/centos-swap: 3221 MB, 3221225472 bytes, 6291456 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 생성
[root@localhost ~]# pvcreate /dev/xvda3
Physical volume "/dev/xvda3" successfully created.
[root@localhost ~]#
- Pv 생성 확인
[root@localhost ~]# pvscan
PV /dev/xvda2 VG centos lvm2 [<29.00 GiB / 0 free]
PV /dev/xvda3 lvm2 [20.00 GiB] # xvda3 생성 확인
Total: 2 [<49.00 GiB] / in use: 1 [<29.00 GiB] / in no VG: 1 [20.00 GiB]
[root@localhost ~]#
- vg 볼륨 확인
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <29.00 GiB
PE Size 4.00 MiB
Total PE 7423
Alloc PE / Size 7423 / <29.00 GiB
Free PE / Size 0 / 0
VG UUID 9WTMvz-YHOg-AdMY-QCIS-VM90-yJUj-zGlHNP
- vg 그룹 확장
[root@localhost ~]# vgextend centos /dev/xvda3
Volume group "centos" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 48.99 GiB
PE Size 4.00 MiB
Total PE 12542
Alloc PE / Size 7423 / <29.00 GiB
Free PE / Size 5119 / <20.00 GiB
VG UUID 9WTMvz-YHOg-AdMY-QCIS-VM90-yJUj-zGlHNP
- 파티션 용량 증가
[root@localhost ~]# lvscan
ACTIVE '/dev/centos/swap' [3.00 GiB] inherit
ACTIVE '/dev/centos/root' [<26.00 GiB] inherit
[root@localhost ~]# lvextend -l +100%FREE /dev/centos/root
Size of logical volume centos/root changed from <26.00 GiB (6655 extents) to 45.99 GiB (11774 extents).
Logical volume centos/root successfully resized.
[root@localhost ~]#
- Lv용량 증가 확인
[root@localhost ~]# lvscan
ACTIVE '/dev/centos/swap' [3.00 GiB] inherit
ACTIVE '/dev/centos/root' [45.99 GiB] inherit
- Resize 용량 적용
[root@localhost ~]# resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock.
위 처럼 에러 발생 시 xfs 파일시스템 적용 방법 진행 해야됨
- Xfs 파일시스템 적용
[root@localhost ~]# blkid /dev/mapper/centos-root
/dev/mapper/centos-root: UUID="3701b65c-3a57-4634-94f3-60715f84e9ec" TYPE="xfs"
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=1703680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=6814720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3327, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 6814720 to 12056576
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 9.4M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 46G 7.7G 39G 17% /
/dev/xvda1 1014M 202M 813M 20% /boot
tmpfs 781M 8.0K 781M 1% /run/user/42
tmpfs 781M 0 781M 0% /run/user/0
[root@localhost ~]#
728x90
'IT > LINUX' 카테고리의 다른 글
linux magaraid gui 설치 방법 (0) | 2023.11.09 |
---|---|
rocky8 Glusterfs 구성 (0) | 2023.11.07 |
linux Network OS 설치 하기 - PXE 서버 구성 (0) | 2023.05.08 |
Linux에서 NFS 서버를 설정하는 방법 (0) | 2023.05.03 |
서버 ping 체크 스크립트 (2) | 2023.04.20 |