LVM 디스크 크기 확장

LVM 디스크 크기 확장

현재 물리 볼륨(/dev/sdb1)에 170G LVM(/dev/data/files)이 있습니다. 이것은 lsblk 명령으로 표시되는 구조입니다.

lsblk
sdb                 8:16   0   220G  0 disk
└─sdb1              8:17   0   170G  0 part
  └─files           253:2  0   170G  0 lvm  /mnt/data

내가 한 일은 다음과 같습니다.

220G 이상에서 볼 수 있듯이 물리 볼륨에 50G를 추가했으므로 이제 fdisk -l /dev/sdb 명령을 실행하면 새로 추가된 크기가 표시됩니다.

fdisk -l /dev/sdb
Disk /dev/sdb: 236.2 GB, 236223201280 bytes, 461373440 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes

내가 하고 싶은 것: LVM /mnt/data에 50G 크기를 추가하고 싶습니다. 현재는 170G입니다.

lvdisplay -vm /dev/data/files
  --- Logical volume ---
  LV Path                /dev/data/files
  LV Name                data
  VG Name                vgdata
  LV UUID                5abc1M-yBeb-Vzxc-d6mK-yqwe-iyui-glkjL
  LV Write Access        read/write
  LV Creation host, time myvm, 2020-04-09 12:27:06 -0300
  LV Status              available
  LV Size                <170.00 GiB
  Current LE             43519
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

  --- Segments ---
  Logical extents 0 to 43518:
    Type                linear
    Physical volume     /dev/sdb1
    Physical extents    0 to 43518

또한 sdb1의 fdisk 명령은 다음과 같습니다.

fdisk -l /dev/sdb1
Disk /dev/sdb1: 182.5 GB, 182535061504 bytes, 356513792 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes

그렇다면...170G 대신 220G에 맞게 볼륨 크기를 어떻게 확장합니까? 이것이 나의 주요 목표이지만 어떻게 해야 할지 모르겠습니다.

저를 도와주시는 모든 분들께 미리 감사드립니다!

편집하다:

출력 아래에서 두 가지 명령을 실행했습니다.

명령 1

lvextend -l +100%FREE /dev/mapper/files
New size (43519 extents) matches existing size (43519 extents)

명령 2

resize2fs /dev/mapper/files
The filesystem is already 44563456 blocks long.  Nothing to do!

유효한지 확인하는 명령 3

lvs
files vgfiles -wi-ao---- <170.00g

치수는 여전히 동일합니다.

답변1

찾고 있는 명령은 lvextend& then 입니다.resize2fs

 lvextend -L somesize  /dev/mapper/LV_NAME

그런 다음 새 공간을 활성화/사용 가능하게 만듭니다.

resize2fs /dev/mapper/LV_NAME

100% sdb를 사용하고 싶다면

lvextend -l +100%FREE  /dev/mapper/LV_name

lvs 명령에서 LV_name을 얻거나 UUID를 사용할 수 있습니다.(명령 매개변수 조정)

실제 상황 예:

:~# lvs
  LV         VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  LV_example example   -wi-a-----  <2,93g                                                    
  lvar2      zaphod-vg -wi-ao---- <14,00g                                                    
  opt        zaphod-vg -wi-ao----   8,00g                                                    
  slash      zaphod-vg -wi-ao----  80,00g                                                    
  srv        zaphod-vg -wi-ao----   4,00g                                                    
  tmp        zaphod-vg -wi-ao----   4,00g                                                    
  usr        zaphod-vg -wi-ao---- 128,00g                                                    
:~# pvcreate /dev/sdh1
  Physical volume "/dev/sdh1" successfully created.
:~# vgs
  VG        #PV #LV #SN Attr   VSize    VFree  
  example     1   1   0 wz--n-    3,73g 820,00m
  zaphod-vg   1   6   0 wz--n- <238,00g      0 
root@zaphod:~# vgextend vg /dev/sdh1 
  Volume group "vg" not found
  Cannot process volume group vg
:~# vgextend example /dev/sdh1 ## the step you didn't do I think
  Volume group "example" successfully extended
:~# vgs
  VG        #PV #LV #SN Attr   VSize    VFree
  example     2   1   0 wz--n-    7,46g 4,53g
  zaphod-vg   1   6   0 wz--n- <238,00g    0 

이제 USB 플래시 드라이브는 새로운 4Go의 VG에 충분하므로 사용 lvextend -l 100%Free후 새로운 공간을 확보하게 됩니다.

VGextend 단계가 없으면 사용 가능한 VG 크기의 100%로 LV를 확장하는 것과 동일한 크기이며 물론 효과가 없습니다.

관련 정보