[Linux] Rocky Linux 9.5 LVM Thin Provisioning Thin Pool & Thin Volume 구성하기






1. 개요

  • LVM 환경에서 Thin Pool과 Thin Volume을 생성하고, ext4·XFS 파일시스템으로 마운트한 뒤, lvs 명령어로 사용 현황을 확인하는 과정을 다룹니다.
  • 씬 프로비저닝(Thin Provisioning) 기능을 통해 실제 디스크 용량보다 큰 가상 용량을 할당하는 방식을 실습합니다.



2. 버전

  • Rocky Linux 9.5



3. 설명




3-1. Thin Provisioning 이란?

  • 스토리지 가상화 기법 중 하나로, 실제 물리적 디스크 용량을 즉시 전부 할당하지 않고 **필요할 때(on-demand)**만 공간을 차지하도록 하는 방식입니다.
  • 예시 : 5GB의 실제 공간(Thin Pool)을 가지고 있으면서도, 사용자에게는 10GB·20GB짜리 논리 볼륨(Thin Volume)을 제공할 수 있습니다.
    • 장점: 디스크 활용 효율 극대화, 불필요한 낭비 방지
    • 단점: 실제 물리 디스크가 가득 차면 데이터 손상 위험이 있으므로 반드시 모니터링 필요



3-2. Thin Pool 이란?

  • LVM에서 씬 프로비저닝을 구현하는 저장소 영역입니다.
  • 실제 물리 디스크 공간을 Thin Pool로 만들어 두면, 그 위에 여러 개의 Thin Volume을 생성할 수 있습니다.
  • 내부적으로 **데이터 영역(Data Block)**과 **메타데이터 영역(Metadata Block)**으로 나뉘어 관리됩니다.
    • 데이터 영역: 실제 쓰이는 사용자 데이터 저장소
    • 메타데이터 영역: 어느 블록이 할당/해제되었는지 추적



3-3. Thin Volume 이란?

  • Thin Pool 위에 만들어지는 논리 볼륨(LV)입니다.
  • 생성 시 지정하는 용량은 **가상 크기(Virtual Size)**일 뿐, 실제 공간은 Thin Pool에서 데이터가 쓰일 때만 차지합니다.
  • 예시 : Thin Pool(5GB) 위에 thin_ext4(10GB)thin_xfs(10GB)를 생성할 수 있음 → 총 20GB 가상 용량이지만 실제 공간은 5GB 내에서 관리됨.
  • 일반 LV와 달리, lvs 명령어로 Data% / Meta% 사용률을 추적하는 것이 중요합니다.



4. Partition 설정

# parted -s /dev/vdd mklabel gpt
# parted -s /dev/vdd mkpart vdb 1 100%
# parted -s /dev/vdd set 1 lvm on



5. PV(Physical Volume)




5-1. PV 생성

# pvcreate /dev/vdd1


출력 예시:

  Physical volume "/dev/vdd1" successfully created.


5-2. PV 생성 확인

# pvdisplay /dev/vdd1


출력 예시:

  "/dev/vdd1" is a new physical volume of "<128.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdd1
  VG Name
  PV Size               <128.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               bgCCtx-hOvx-aDCS-SR0f-ouD5-ux0R-2KyUy5



6. VG(Volume Group)




6-1. VG 확장

# vgextend vgtest /dev/vdd1


출력 예시:

  Volume group "vgtest" successfully extended



6-2. VG 확장 확인

# vgdisplay vgtest


출력 예시:

  --- Volume group ---
  VG Name               vgtest
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  24
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               <383.99 GiB
  PE Size               4.00 MiB
  Total PE              98301
  Alloc PE / Size       8960 / 35.00 GiB
  Free  PE / Size       89341 / <348.99 GiB
  VG UUID               6wo6Q6-VcLA-mBVw-U9AF-nySN-Uu3x-jKHgbh



7. LV(Logical Volume)




7-1. Thin Pool 생성

# lvcreate -T -L 5G -n thinpool vgtest


출력 예시:

  Thin pool volume with chunk size 64.00 KiB can address at most <15.88 TiB of data.
  Logical volume "thinpool" created.



7-2. Thin Volume 생성

# lvcreate -V 10G -T vgtest/thinpool -n thin_ext4


출력 예시:

  WARNING: Sum of all thin volume sizes (10.00 GiB) exceeds the size of thin pool vgtest/thinpool (5.00 GiB).
  WARNING: You have not turned on protection against thin pools running out of space.
  WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
  Logical volume "thin_ext4" created.


# lvcreate -V 10G -T vgtest/thinpool -n thin_xfs


출력 예시:

  WARNING: Sum of all thin volume sizes (20.00 GiB) exceeds the size of thin pool vgtest/thinpool (5.00 GiB).
  WARNING: You have not turned on protection against thin pools running out of space.
  WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
  Logical volume "thin_xfs" created.



8. 파일 시스템 생성 및 마운트




8-1. 파일 시스템 생성

# mkfs.ext4 /dev/vgtest/thin_ext4
# mkfs.xfs /dev/vgtest/thin_xfs



8-2. 마운트

# mkdir -p /mnt/thin_ext4 /mnt/thin_xfs
# mount -o discard /dev/vgtest/thin_ext4 /mnt/thin_ext4
# mount -o discard /dev/vgtest/thin_xfs  /mnt/thin_xfs



8-3. 마운트 확인

# df -Th | grep thin


출력 예시:

/dev/mapper/vgtest-thin_ext4 ext4      9.8G   24K  9.3G   1% /mnt/thin_ext4
/dev/mapper/vgtest-thin_xfs  xfs        10G  104M  9.9G   2% /mnt/thin_xfs



9. 사용 현황 확인

  • Data% : 실제 데이터 사용률
  • Meta% : 메타데이터 사용률


# lvs -a -o+segtype,lv_size,data_percent,metadata_percent vgtest


출력 예시:

  LV               VG     Attr       LSize  Pool     Origin Data%  Meta%  Move Log Cpy%Sync Convert Type      LSize  Data%  Meta%
  lv_ext4          vgtest -wi-ao---- 15.00g                                                         linear    15.00g
  lv_xfs           vgtest -wi-ao---- 20.00g                                                         linear    20.00g
  [lvol0_pmspare]  vgtest ewi-------  8.00m                                                         linear     8.00m
  thin_ext4        vgtest Vwi-aotz-- 10.00g thinpool        2.24                                    thin      10.00g 2.24
  thin_xfs         vgtest Vwi-aotz-- 10.00g thinpool        0.64                                    thin      10.00g 0.64
  thinpool         vgtest twi-aotz--  5.00g                 5.75   11.91                            thin-pool  5.00g 5.75   11.91
  [thinpool_tdata] vgtest Twi-ao----  5.00g                                                         linear     5.00g
  [thinpool_tmeta] vgtest ewi-ao----  8.00m                                                         linear     8.00m



댓글 남기기