1

I am new to LVM so please excuse any silly questions. I created a VM on VMWare and edited the settings to extend the disk space from 40 to 80GB. Later i realized that i need to use LVM to actually extend the disk space. Since my output of df -h still shows 40GB.

Filesystem                         Size  Used Avail Use% Mounted on
udev                               2.0G     0  2.0G   0% /dev
tmpfs                              396M  5.7M  390M   2% /run
/dev/mapper/ubuntu--prod--vg-root   38G  2.5G   34G   7% /
tmpfs                              2.0G   68K  2.0G   1% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sda1                          720M  109M  575M  16% /boot
tmpfs                              396M     0  396M   0% /run/user/1001

So, currently when i run fdisk -l, this is my output :-

Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 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
Disklabel type: dos
Disk identifier: 0x34a96e3a

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       2048  1499135  1497088  731M 83 Linux
/dev/sda2       1501182 83884031 82382850 39.3G  5 Extended
/dev/sda5       1501184 83884031 82382848 39.3G 8e Linux LVM


Disk /dev/mapper/ubuntu--prod--vg-root: 38.3 GiB, 41150316544 bytes, 80371712 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


Disk /dev/mapper/ubuntu--prod--vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 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

and sudo pvdisplay shows the following option :-

--- Physical volume ---
  PV Name               /dev/sda5
  VG Name               ubuntu-prod-vg
  PV Size               39.28 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              10056
  Free PE               0
  Allocated PE          10056
  PV UUID               lUfzd9-1BVL-0XGA-YJPI-Roxe-Vb7p-Wdstfb

So i have a couple of questions.

  1. Am i understanding it right that /dev/sda5 is currently part of the volume group that is in use?
  2. If /dev/sda5 in infact in use, the does it mean i would need to add /dev/sda2 to the volume group to get the desired disk space?
  3. When i try to run sudo pvcreate /dev/sda2 i am running into Device /dev/sda2 not found (or ignored by filtering).

So how can i extend the disk space? what am i doing wrong and what would be the right approach? Thank you for the assistance.

1 Answer 1

1

You need to resize both sda2 and sda5 first using fdisk or parted. sda2 is an extended partition, sda5 (which is your PV) is a logical partition "inside" sda2 so you need to resize sda2 first and then sda5.

After you resize the partitions you need to use pvresize to resize the PV format. pvresize /dev/sda2 will be enough, without the size argument it will resize the PV to the size of the partition.

After that you just need to resize your root logical volume with lvresize --resizefs -L+100%FREE ubuntu-prod-vg/root.

As always when working with storage, make sure to backup your data first.

1
  • Thank you and can you please point me as to how should i go about resizing using fdisk? Commented Mar 18, 2022 at 21:19

You must log in to answer this question.

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