0

I am trying to extend a logical volume size of a partition in a vmware environment. The VM originally was configured with a single 60 GB HDD and partitions look like as follows:

lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   60G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   59G  0 part 
  ├─c7-root     253:0    0   25G  0 lvm  /
  ├─c7-swap     253:1    0    6G  0 lvm  [SWAP]
  ├─c7-var_temp 253:2    0  3.7G  0 lvm  /var/tmp
  ├─c7-home     253:3    0 20.6G  0 lvm  /home
  └─c7-tmp      253:4    0  3.7G  0 lvm  /tmp
sr0              11:0    1 1024M  0 rom

However, now we have decided to extend the HDD to 80 GB, unmount /var/tmp and remount /var into the newly added extra 20 GB + the old space reclaimed after deleting /var/tmp

Extending the HDD to 80 GB was easily achieved via the vmware webclient, however, I'm not sure how to delete the /var/tmp and create a new LVM to mount /var.

After extending the HDD, lsblk yields

lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   80G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   59G  0 part 
  ├─c7-root     253:0    0   25G  0 lvm  /
  ├─c7-swap     253:1    0    6G  0 lvm  [SWAP]
  ├─c7-var_temp 253:2    0  3.7G  0 lvm  /var/tmp
  ├─c7-home     253:3    0 20.6G  0 lvm  /home
  └─c7-tmp      253:4    0  3.7G  0 lvm  /tmp
sr0              11:0    1 1024M  0 rom

The sda partition now reports 80G, however, vgdisplay still reports the VG size as 59G

  --- Volume group ---
  VG Name               C7
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                5
  Open LV               5
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <59.00 GiB
  PE Size               4.00 MiB
  Total PE              15103
  Alloc PE / Size       15100 / 58.98 GiB
  Free  PE / Size       3 / 12.00 MiB
  VG UUID               XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Further, the pvdisplay displays

  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               C7
  PV Size               <59.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              15103
  Free PE               3
  Allocated PE          15100
  PV UUID               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

So not sure how to extent the physical volume without deleting other partitions and subsequently create the logical volume.

1 Answer 1

2
  1. Resize the /dev/sda2 partition using fdisk or parted. You might also need to fix the partition table on /dev/sda (the tools should be able do that automatically).
  2. Resize the PV on it using pvresize /dev/sda2 (no size means it should be adjusted to device's size).
  3. Create new logical volume using lvcreate.
  4. Mount the new LV to /var (you'll need to update /etc/fstab).

pvresize can work on PVs with active logical volumes, but I'd strongly recommend doing this offline and of course backup all important data first.

If you need more information about working with LVM volumes, I recommend this documentation from RHEL (works for all distributions).

Note: Resizing disks with partitions isn't the best idea. It would be way better to add a second disk, create PV on it using pvcreate and add it to the volume group using vgextend.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.