0

I have a LVM (/dev/data/files) with 170G which is currently on a Physical volume (/dev/sdb1) Here is the structure, shown by lsblk command

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

What i did was:

I added 50G on Physical volume, as you can see above with 220G so now when i execute the command fdisk -l /dev/sdb it shows the new added size to it.

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

What i wanna do: I want to add that 50G size to the LVM /mnt/data Currently it has only 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

Also, the command fdisk on sdb1:

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

So... How do i extend the volume size to fit 220G instead of 170G? Thats my main objective and i do not know how to do that.

Thanks in advance for everyone that helps me!

Edit:

I executed two commands, below the output:

Command 1

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

Command 2

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

Command 3 to check if it worked

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

Size still the same.

1
  • Your question does not appear to show that you added the 50Gb as physical volume, then added that to the volume group. You'll have to do each step (physical, volume, logical) in succession to lvextend to have an effect. (This actually calls for a tutorial, and asking here invites poor answers). Nov 17, 2021 at 20:34

1 Answer 1

0

the command you're looking for is lvextend & then resize2fs

 lvextend -L somesize  /dev/mapper/LV_NAME

and then make the new space active/available for use

resize2fs /dev/mapper/LV_NAME

if you are sure you want to use 100% of sdb

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

You can get LV_name from lvs command or use the UUID (adapt command parameters)

real condition example :

:~# 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 

now the USB sticks are ok to VG with new 4Go so then using lvextend -l 100%Free will get the new space

Without the VGextend step, its size remains the same as expanding LV with 100% of free VG size didn't have any effect, of course.

6
  • Hello! Yes, i executed those two commands but here is the thing: It didnt work. The size stayed the same! I edited the question and gave it the output. Nov 17, 2021 at 20:25
  • you might forgot to add the phisical volume to the VG then ; but it is the first thing to do regarding on you question syntax I've supposed you did. the use vgextend
    – francois P
    Nov 17, 2021 at 20:52
  • What do you mean by add the phisical volume to the vg? Nov 17, 2021 at 20:55
  • the VG keeps its size until you expand it to size of the allready present PV + new PVs you want to add to the VG and then the LV (see that all as a stack of 3 elements) LV <= VG <= PV ; I'll add a full end-to-end example on the answer to more more clear ;) wait a few minutes
    – francois P
    Nov 17, 2021 at 21:02
  • Oh, okay. So i have to first increase Physical Volume then i increase Volume Group? But how do i increase Physical Volume tho? Can i delete the partition and create it again with new space then transform into Physical Volume again or if i use the same partition ID the Physical Volume updates automatically? Nov 18, 2021 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .