Operating System/Linux
Linux7.9 LVM 확장
Growing DBA
2025. 2. 14. 11:11
728x90
반응형
* 하드디스크 추가 : /dev/sdg (VDI-고정크기-20G)
1. 기존 디스크 확장
[root@RAC1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdf 8:80 0 15G 0 disk
└─sdf1 8:81 0 15G 0 part
sdd 8:48 0 1G 0 disk
└─sdd1 8:49 0 1023M 0 part
sdb 8:16 0 1G 0 disk
└─sdb1 8:17 0 1023M 0 part
sr0 11:0 1 1024M 0 rom
sdg 8:96 0 20G 0 disk
sde 8:64 0 15G 0 disk
└─sde1 8:65 0 15G 0 part
sdc 8:32 0 1G 0 disk
└─sdc1 8:33 0 1023M 0 part
sda 8:0 0 48G 0 disk
├─sda2 8:2 0 47G 0 part
│ ├─ol-swap 252:1 0 4.8G 0 lvm [SWAP]
│ └─ol-root 252:0 0 42.2G 0 lvm /
└─sda1 8:1 0 1G 0 part /boot
2. 파티션 생성
[root@RAC1 ~]# fdisk /dev/sdg
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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x4a4fe52d.
Command (m for help): n -----> #파티션 생성
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p ----->#primary 파티션 생성
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): p ----->#파티션 확인
Disk /dev/sdg: 21.5 GB, 21474836480 bytes, 41943040 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: 0x4a4fe52d
Device Boot Start End Blocks Id System
/dev/sdg1 2048 41943039 20970496 83 Linux
Command (m for help): t ----->#파티션 타입 설정
Selected partition 1
Hex code (type L to list all codes): 8e ----->#파티션 타입 코드
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdg: 21.5 GB, 21474836480 bytes, 41943040 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: 0x4a4fe52d
Device Boot Start End Blocks Id System
/dev/sdg1 2048 41943039 20970496 8e Linux LVM
Command (m for help): w ----->#설정 저장
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3. PV 생성
[root@RAC1 ~]# pvcreate /dev/sdg1
Physical volume "/dev/sdg1" successfully created.
[root@RAC1 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name ol
PV Size <47.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12031
Free PE 0
Allocated PE 12031
PV UUID tfZaV5-Yjik-eP0o-nic4-RBl0-dmbj-awXirZ
"/dev/sdg1" is a new physical volume of "<20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdg1
VG Name
PV Size <20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID tALH2Y-Vf2k-6Qrj-O1Po-GltN-CAZS-FGyTEK
4. VG 확장
[root@RAC1 ~]# vgdisplay
--- Volume group ---
VG Name ol
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 <47.00 GiB
PE Size 4.00 MiB
Total PE 12031
Alloc PE / Size 12031 / <47.00 GiB
Free PE / Size 0 / 0
VG UUID 08FN3M-t7Rz-9qVv-Xh85-wvCd-k0PR-x3w1wX
[root@RAC1 ~]# vgextend ol /dev/sdg1
Volume group "ol" successfully extended
[root@RAC1 ~]# vgdisplay
--- Volume group ---
VG Name ol
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 66.99 GiB
PE Size 4.00 MiB
Total PE 17150
Alloc PE / Size 12031 / <47.00 GiB
Free PE / Size 5119 / <20.00 GiB
VG UUID 08FN3M-t7Rz-9qVv-Xh85-wvCd-k0PR-x3w1wX
5. LV 확장
[root@RAC1 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/ol/swap
LV Name swap
VG Name ol
LV UUID LCxopt-cdeN-6i1j-AaXM-IEjh-sKIs-jf7NyF
LV Write Access read/write
LV Creation host, time localhost, 2024-08-26 12:58:56 +0900
LV Status available
# open 2
LV Size 4.80 GiB
Current LE 1229
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:1
--- Logical volume ---
LV Path /dev/ol/root
LV Name root
VG Name ol
LV UUID w5TATW-cvHx-fGoE-AH3i-QAmA-2OHl-f39Rgn
LV Write Access read/write
LV Creation host, time localhost, 2024-08-26 12:58:57 +0900
LV Status available
# open 1
LV Size <42.20 GiB
Current LE 10802
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:0
6. 리사이즈
[root@RAC1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 4.0G 893M 3.2G 22% /dev/shm
tmpfs 3.9G 9.4M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/ol-root 43G 27G 16G 65% /
/dev/sda1 1014M 224M 791M 23% /boot
tmpfs 796M 12K 796M 1% /run/user/42
tmpfs 796M 0 796M 0% /run/user/1000
tmpfs 796M 0 796M 0% /run/user/0
#####파일 시스템 종류 확인
xfs인 경우 -> xfs_growfs
ext4 인 경우 -> resize2fs
[root@RAC1 ~]# blkid /dev/sd*
/dev/sda: PTTYPE="dos"
/dev/sda1: UUID="c60d1642-98e0-495e-86a3-782b1d4da6ce" TYPE="xfs"
/dev/sda2: UUID="tfZaV5-Yjik-eP0o-nic4-RBl0-dmbj-awXirZ" TYPE="LVM2_member"
/dev/sdb: PTTYPE="dos"
/dev/sdb1: LABEL="CRS1" TYPE="oracleasm"
/dev/sdc: PTTYPE="dos"
/dev/sdc1: LABEL="CRS2" TYPE="oracleasm"
/dev/sdd: PTTYPE="dos"
/dev/sdd1: LABEL="CRS3" TYPE="oracleasm"
/dev/sde: PTTYPE="dos"
/dev/sde1: LABEL="DATA" TYPE="oracleasm"
/dev/sdf: PTTYPE="dos"
/dev/sdf1: LABEL="FRA" TYPE="oracleasm"
/dev/sdg: PTTYPE="dos"
/dev/sdg1: UUID="tALH2Y-Vf2k-6Qrj-O1Po-GltN-CAZS-FGyTEK" TYPE="LVM2_member"
[root@RAC1 ~]# lvextend -L +5G /dev/ol/root
Size of logical volume ol/root changed from <42.20 GiB (10802 extents) to <47.20 GiB (12082 extents).
Logical volume ol/root successfully resized.
[root@RAC1 ~]# lvextend -L +10G /dev/ol/root
Size of logical volume ol/root changed from <47.20 GiB (12082 extents) to <57.20 GiB (14642 extents).
Logical volume ol/root successfully resized.
[root@RAC1 ~]# lvextend -L +4G /dev/ol/root
Size of logical volume ol/root changed from <57.20 GiB (14642 extents) to <61.20 GiB (15666 extents).
Logical volume ol/root successfully resized.
[root@RAC1 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root ol -wi-ao---- <61.20g
swap ol -wi-ao---- 4.80g
[root@RAC1 ~]# xfs_growfs /dev/ol/root
meta-data=/dev/mapper/ol-root isize=256 agcount=4, agsize=2765312 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=11061248, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=5401, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 11061248 to 16041984
[root@RAC1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 4.0G 893M 3.2G 22% /dev/shm
tmpfs 3.9G 9.4M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/ol-root 62G 27G 35G 45% /
/dev/sda1 1014M 224M 791M 23% /boot
tmpfs 796M 12K 796M 1% /run/user/42
tmpfs 796M 0 796M 0% /run/user/1000
tmpfs 796M 0 796M 0% /run/user/0
728x90
반응형