- 파티션 구조와 상관 없이 원하는 크기로 생성(확장성)
- 사용 중 사이즈가 부족하면 확장 가능
- 디스크 교체 작업이 수월(데이터 유지한 채로 교체 가능)
- RAID를 적용한 볼륨 생성 가능
- 특정 시점을 저장하는 snapshot 기능
- 실제 장치 하나의 크기보다 더 크게 사용 가능(여러 장치 연결)
물리볼륨 -> 볼륨 그룹 -> 논리 볼륨
물리적인 실제 장치를 의미 (파티션/디스크)
PV의 집합
실제 사용할 논리적 단위(VG 안에 생성)
n옵션과 t옵션을 활용하여 LVM(8e), swap(82)파티션 생성

# pv create
pvcreate /dev/sdd7 /dev/sdd8 /dev/sdd9 /dev/sdd10
Physical volume "/dev/sdd7" successfully created.
Physical volume "/dev/sdd8" successfully created.
Physical volume "/dev/sdd9" successfully created.
Physical volume "/dev/sdd10" successfully created.
# VG create test-vg라는 이름으로 7,8,9번 파티션 할당
vgcreate test-vg /dev/sdd7 /dev/sdd8 /dev/sdd9
Volume group "test-vg" successfully created
# LV create 실제 사용할 LV 생성
# test-vg VG에서 2G 크기 (-L)를 사용해 test-lv라는 LV 생성
lvcreate -n test-lv -L 2G test-vg
Logical volume "test-lv" created.
# 소문자 l옵션 사용 시 뒤의 인자 수 만큼 pe 생성하여 용량 할당
lvcreate -l 100 test-vg
Volume group "test-vg" successfully extended
# vgdisplay
lvol0 test-vg -wi-a----- 400.00m
# 직접 용량 할당도 가능
lvcreate -L 400M test-vg



mkfs -t < filesystem > < Path >
# path 조회
lvdisplay | grep Path
Devices file sys_wwid t10.ATA_VBOX_HARDDISK_VBa64d3d26-8dd3a5f6 PVID bbyAlJIN9bj4rcDjcYVVqMBz72umwe05 last seen on /dev/sda2 not found.
LV Path /dev/test-vg/test-lv
# format
mkfs -t xfs /dev/test-vg/test-lv
mount /dev/test-vg/test-lv /mnt/lvm/

/dev/test-vg/test-lv /mnt/lvm xfs defaults 0 0
기존에 할당되어있지 않던 장치를 추가해주는 용량 scaling이 가능하다.
vgextend test-vg /dev/sdd10
Volume group "test-vg" successfully extended
vgdisplay | grep -i size
Devices file sys_wwid t10.ATA_VBOX_HARDDISK_VBa64d3d26-8dd3a5f6 PVID bbyAlJIN9bj4rcDjcYVVqMBz72umwe05 last seen on /dev/sda2 not found.
VG Size 3.98 GiB
PE Size 4.00 MiB
Alloc PE / Size 512 / 2.00 GiB
Free PE / Size 508 / 1.98 GiB
# 원하는 용량을 바로 입력하거나 더하는 방식 모두 가능하여 아래의 두 줄은 같은 의미를 가지며 -r(resize)옵션을 사용해줘야한다.
lvextend -L 2.5G /dev/test-vg/test-lv -r
lvextend -L +500M /dev/test-vg/test-lv -r
# lvdisplay 명령으로 확인
LV Size <2.49 GiB
umount /mnt/lvm
lvremove /dev/test-vg/test-lv
Do you really want to remove active logical volume test-vg/test-lv? [y/n]: y
Logical volume "test-lv" successfully removed.
vgremove test-vg
Do you really want to remove volume group "test-vg" containing 1 logical volumes? [y/n]: y
Do you really want to remove active logical volume test-vg/lvol0? [y/n]: y
Logical volume "lvol0" successfully removed.
Volume group "test-vg" successfully removed
pvremove /dev/sdd10
Labels on physical volume "/dev/sdd10" successfully wiped.
pvremove /dev/sdd9
Labels on physical volume "/dev/sdd9" successfully wiped.
fdisk
pvcreate
vgcreate
lvcreate
mkfs -t
filesystemmount
umount
lvremove
vgremove
pvremove
fdisk
pvcreate
vgextend
lvextent
- vgreduce
vgdevice- pvremove
- fdisk
도움이 됩니다^^