로그인

검색

[ubuntu server 22.04. 3 LTS (Jammy Jellyfish)] LVM 어떻게 처리할까? (확장하기)

[ubuntu server 22.04. 3 LTS (Jammy Jellyfish)] LVM 어떻게 처리할까? (확장하기)

 

라즈베리파이4 에서는 볼 수 없었던, LVM 파일 시스템이었습니다.

 

LVM 이란?

- 자유롭게 확장, 축소가 가능한 형태의 저장소 입니다.

  흔히, 아래와 같은 경우에 효과적으로 사용가능합니다.

  서버에 하드디스크가 여러개 물려있고, 각 저장소 마다, 아주 조금씩 free space 가 남아있을때,

  LVM 을 이용하면, 흩어져 있는 free space 를 끌어 보아,

  겉으로 보기엔, 마치 하나의 저장소에 존재하는 free space 처럼 보이고, 작동하게 합니다. 

 

 

500G 하드가 연결되어 있는데, LVM 이 100G 만 사용중입니다.

hs7@hansung:~$ lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0 111.9M  1 loop /snap/lxd/24322
loop1                       7:1    0  63.4M  1 loop /snap/core20/1974
loop2                       7:2    0  53.3M  1 loop /snap/snapd/19457
sda                         8:0    0 465.8G  0 disk
├─sda1                      8:1    0     1M  0 part
├─sda2                      8:2    0     2G  0 part /boot
└─sda3                      8:3    0 463.8G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0   100G  0 lvm  /
sdb                         8:16   0 465.8G  0 disk
├─sdb1                      8:17   0 237.4G  0 part
├─sdb2                      8:18   0    33G  0 part
├─sdb3                      8:19   0  78.1G  0 part
├─sdb4                      8:20   0     1K  0 part
└─sdb5                      8:21   0 117.2G  0 part

 

 

LVM 을 삭제 하려고 했더니, root 에서 사용중 이네요.

할수없이, LVM 을 확장하기로 했습니다. (위에서 sda3 전체를 사용하려고 합니다.)

 

 

디스크 사용형태를 봅니다.

hs7@hcp:~$ sudo df -Th
Filesystem                        Type     Size  Used Avail Use% Mounted on
tmpfs                             tmpfs    784M  2.1M  782M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4      98G   32G   62G  34% /
tmpfs                             tmpfs    3.9G  1.2M  3.9G   1% /dev/shm
tmpfs                             tmpfs    5.0M     0  5.0M   0% /run/lock
/dev/sda2                         ext4     2.0G  253M  1.6G  14% /boot
overlay                           overlay   98G   32G   62G  34% /var/lib/docker/overlay2/befcab517a4259f84ec15b8e469d6ded69ce471d2a63773ac20e25b2f6dc4e23/merged
overlay                           overlay   98G   32G   62G  34% /var/lib/docker/overlay2/477ff7df00ff19dd3371cb518610acb7003456c7fc9188e6713574824c347179/merged
overlay                           overlay   98G   32G   62G  34% /var/lib/docker/overlay2/ed61d7d8b02358046c271000571e41def3e2cd1108b0f30bd7ada5b141523e8a/merged
overlay                           overlay   98G   32G   62G  34% /var/lib/docker/overlay2/190d165baf87c0aa220305e56ca21f2cf28528fce6306b446a255422fc187f15/merged
overlay                           overlay   98G   32G   62G  34% /var/lib/docker/overlay2/95efcc11611583d577d889b368e2ef33228b442fa87a12902378eb2d8769d13d/merged
overlay                           overlay   98G   32G   62G  34% /var/lib/docker/overlay2/d258a901613cdde2ff8d0bf7c8bef52c46cc40b96e5baf044477590e4885477e/merged
tmpfs                             tmpfs    784M  4.0K  784M   1% /run/user/1000
overlay                           overlay   98G   32G   62G  34% /var/lib/docker/overlay2/db2d270a52332944ea5faea743bc47dd7212f19ba75f0ce6af83d004571dae40/merged

 

 

free space 가 있는지 알아 봅니다.

hs7@hcp:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  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               <463.76 GiB
  PE Size               4.00 MiB
  Total PE              118722
  Alloc PE / Size       25600 / 100.00 GiB
  Free  PE / Size       93122 / <363.76 GiB
  VG UUID               0N3yUl-uX2y-fwf1-WLOF-uxxy-z53O-3Xknj3

 

 

 

free space 를 확인 했으면, LV 경로를 알아야 합니다.

 

hs7@hcp:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                jtoLjB-mSiJ-aPGi-pffA-jSjl-BJTP-HR0toM
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2023-09-28 10:37:16 +0000
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

 

 

100% 모두 확장해 봅니다.

 

hs7@hcp:~$ sudo lvextend -l +100%FREE -r /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <463.76 GiB (118722 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 58
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 121571328 (4k) blocks long.

 

 

 

hs7@hcp:~$ lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0  63.4M  1 loop /snap/core20/1974
loop1                       7:1    0  63.5M  1 loop /snap/core20/2015
loop2                       7:2    0 111.9M  1 loop /snap/lxd/24322
loop3                       7:3    0  53.3M  1 loop /snap/snapd/19457
loop4                       7:4    0  40.8M  1 loop /snap/snapd/20092
sda                         8:0    0 465.8G  0 disk
├─sda1                      8:1    0     1M  0 part
├─sda2                      8:2    0     2G  0 part /boot
└─sda3                      8:3    0 463.8G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0 463.8G  0 lvm  /

sdb                         8:16   0 465.8G  0 disk
├─sdb1                      8:17   0 237.4G  0 part
├─sdb2                      8:18   0    33G  0 part
├─sdb3                      8:19   0  78.1G  0 part
├─sdb4                      8:20   0     1K  0 part
└─sdb5                      8:21   0 117.2G  0 part

 

 

image.png

 

이 게시물을

이 댓글을 삭제하시겠습니까?