Skip to main content

lvm 볼륨 확장 및 파일시스템 용량 확장 작업

xfs로 만들어진 경로의 데이터 사용량 증가하고 있어 추가로 디스크 장착 ~ 용량 확장하려고 합니다.

 

사전정보

  1. 현재 알람이 발생한 디스크 사용량 정보
    $>  df -Th /data
    Filesystem                        Type  Size  Used Avail Use% Mounted on
    /dev/mapper/content_vg-content_lv xfs   3.6T  3.3T  346G  91% /data
    

    흠.. 3.6T 디스크인데 3.3T사용하고 있어서 총 사용율 91%네요. ㅠ^ㅠ

  2. 굴러다니는 디스크 500G짜리 를 하나 더 붙였습니다.
    $>  fdisk -l 
    ...
    Disk /dev/sdc: 500 GiB, 536870912000 bytes, 1048576000 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
    

  3. vg 이름은 content_vg, lv 이름은 content_lv로 구성이 되어 있어요.

lvm 볼륨 확장

  1. sdc 디스크를 pv 구성해줍니다. (저는 디스크 전체를  lvm으로 사용할꺼라 따로 파티션을 나누진 않았어요)
    $>  pvcreate /dev/sdc
      Physical volume "/dev/sdc" successfully created.
    

  2. pv 정보 확인
    1. 확장 후
      $> pvdisplay 
        --- Physical volume ---
        PV Name               /dev/sdb
        VG Name               content_vg
        PV Size               <3.64 TiB / not usable <1.72 MiB
        Allocatable           yes (but full)
        PE Size               4.00 MiB
        Total PE              953479
        Free PE               0
        Allocated PE          953479
        PV UUID               QnstsS-xBJ0-Qv0l-RFan-SgaA-z3Fg-RJrZK8

    2. 확장 전
      $> pvdisplay 
        --- Physical volume ---
        PV Name               /dev/sdb
        VG Name               content_vg
        PV Size               <3.64 TiB / not usable <1.72 MiB
        Allocatable           yes (but full)
        PE Size               4.00 MiB
        Total PE              953479
        Free PE               0
        Allocated PE          953479
        PV UUID               QnstsS-xBJ0-Qv0l-RFan-SgaA-z3Fg-RJrZK8
         
        --- Physical volume ---
        PV Name               /dev/sdc
        VG Name               content_vg
        PV Size               500.00 GiB / not usable 4.00 MiB
        Allocatable           yes (but full)
        PE Size               4.00 MiB
        Total PE              127999
        Free PE               0
        Allocated PE          127999
        PV UUID               Bsm9b5-DZTB-2iWr-6RH0-6uIy-canP-SOhMeC
      

    3. Volume Group 확장
      $> vgextend content_vg /dev/sdc 
        Volume group "content_vg" successfully extended
      
       
      1. 확장 전
        $> vgdisplay 
          --- Volume group ---
          VG Name               content_vg
          System ID             
          Format                lvm2
          Metadata Areas        1
          Metadata Sequence No  5
          VG Access             read/write
          VG Status             resizable
          MAX LV                0
          Cur LV                1
          Open LV               1
          Max PV                0
          Cur PV                1
          Act PV                1
          VG Size               <3.64 TiB
          PE Size               4.00 MiB
          Total PE              953479
          Alloc PE / Size       943718 / <3.60 TiB
          Free  PE / Size       9761 / <38.13 GiB
          VG UUID               IiEZ8G-kbcL-l8MD-Ax6m-dWSZ-ZTCd-OvBWff
        

      2. 확장 후
        $> vgdisplay 
          --- Volume group ---
          VG Name               content_vg
          System ID             
          Format                lvm2
          Metadata Areas        2
          Metadata Sequence No  6
          VG Access             read/write
          VG Status             resizable
          MAX LV                0
          Cur LV                1
          Open LV               1
          Max PV                0
          Cur PV                2
          Act PV                2
          VG Size               <4.13 TiB
          PE Size               4.00 MiB
          Total PE              1081478
          Alloc PE / Size       943718 / <3.60 TiB
          Free  PE / Size       137760 / 538.12 GiB
          VG UUID               IiEZ8G-kbcL-l8MD-Ax6m-dWSZ-ZTCd-OvBWff
        
        vg Size가 기존 3.64에서 500G를 확장했기 때문에 4.13T로 설정되었어요. lv를 확장하지 않은 상태이기 때문에 Alloc PE가 3.6T, Free PE가 538.12 Gib가 존재하고 있다고 알려주네요.
    4. LV 확장
      $> lvextend -l +100%FREE /dev/content_vg/content_lv
        Size of logical volume content_vg/content_lv changed from <3.60 TiB (943718 extents) to <4.13 TiB (1081478 extents).
        Logical volume content_vg/content_lv successfully resized.
      

       

      남은 공간 모두를 사용할꺼라서 100%FREE라는 옵션을 넣어주면 됩니다.


      1. 확장전
        $> lvdisplay 
          --- Logical volume ---
          LV Path                /dev/content_vg/content_lv
          LV Name                content_lv
          VG Name                content_vg
          LV UUID                fhIWVB-0zNY-IcfO-qhu2-iNqV-hk73-0Nwl0N
          LV Write Access        read/write
          LV Creation host, time container.igoni.kr, 2023-01-08 17:53:28 +0900
          LV Status              available
          # open                 1
          LV Size                <3.60 TiB
          Current LE             943718
          Segments               1
          Allocation             inherit
          Read ahead sectors     auto
          - currently set to     256
          Block device           253:0
        

      2. 확장 후
        $> lvdisplay 
          --- Logical volume ---
          LV Path                /dev/content_vg/content_lv
          LV Name                content_lv
          VG Name                content_vg
          LV UUID                fhIWVB-0zNY-IcfO-qhu2-iNqV-hk73-0Nwl0N
          LV Write Access        read/write
          LV Creation host, time container.igoni.kr, 2023-01-08 17:53:28 +0900
          LV Status              available
          # open                 1
          LV Size                <4.13 TiB
          Current LE             1081478
          Segments               2
          Allocation             inherit
          Read ahead sectors     auto
          - currently set to     256
          Block device           253:0
        

자, 여기까지 진행되었으면 lvm 볼륨을 확장하는것까지 되었고요, 이제 파일시스템 확장을 할 껍니다. 여기까지만 진행되었다면, df -h 쳐도 용량이 늘진 않았어요..

 

  1. 파일시스템 확장
    $> xfs_growfs -d /dev/content_vg/content_lv
    meta-data=/dev/mapper/content_vg-content_lv isize=512    agcount=4, agsize=241591808 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=1, sparse=1, rmapbt=0
             =                       reflink=1    bigtime=0 inobtcount=0
    data     =                       bsize=4096   blocks=966367232, imaxpct=5
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
    log      =internal log           bsize=4096   blocks=471859, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    data blocks changed from 966367232 to 1107433472
    

  2. 파일시스템 용량 확장 확인 (3.6T -> 4.2T로 용량 증설)
    $> df -Th /data
    Filesystem                        Type  Size  Used Avail Use% Mounted on
    /dev/mapper/content_vg-content_lv xfs   4.2T  3.3T  881G  80% /data
    

Reference