LVM resize HOWTO

Запись создана 15 марта, 2024

We have an virtual machine with 165Gb disk, and added extra 10Gb. Now we need to extend filesystem inside a VM

lets check trat extra 10Gb is available in VM

# fdisk -l /dev/sdb
Disk /dev/sdb: 175.2 GiB, 187924742144 bytes, 367040512 sectors

Checkout the physical volume size, it’s 165Gbyte

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb
  VG Name               data
  PV Size               <165.02 GiB / not usable 2.00 MiB

let’s resize it

# pvresize /dev/sdb
  Physical volume "/dev/sdb" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

and check again. ok we see that it extended

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb
  VG Name               data
  PV Size               <175.02 GiB / not usable 2.00 MiB

logical volume is extended to, and have Free Size 10GiB

# vgdisplay
  --- Volume group ---
  VG Name               data
  VG Size               <175.02 GiB
  Alloc PE / Size       42244 / <165.02 GiB
  Free  PE / Size       2560 / 10.00 GiB

now we need to extend logical volume

# lvextend -l +100%FREE /dev/mapper/data-storage
  Size of logical volume data/storage changed from <165.02 GiB (42244 extents) to <175.02 GiB (44804 extents).
  Logical volume data/storage successfully resized.

and resize a file system (in my case it’s xfs)

# xfs_growfs /dev/mapper/data-storage

And now we see that filesystem is growed

# df -h /opt/docker/
Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/data-storage  175G  147G   29G  84% /opt/docker

» Запись из раздела Linux | Комментировать

Комментарии





Ответить