Some time due to excess data the logical volumes are full on Versa Director and we need to have more space in the Existing logical volumes. IN such scenario's we can extend those logical vusing the below procedure. By default on Versa Director we have three LV /opt /var and /root which can be extended.


In the below output we can see the existing partitions

root@s2-vd-1:/home/Administrator# sudo lvs
  LV     VG     Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  opt    system -wi-ao---  9.31g
  root   system -wi-ao--- 12.01g
  swap_1 system -wi-ao--- 29.80g
  var    system -wi-ao--- 27.94g




The first step is to add a new disk on the Versa Director VM which can be done by adding a new HardDisk in KVM. Once you add a new disk it will show up on Director VM as shown below

 

In our case the new disk is sdb. lsblk cmd can also be used to see the newly added disk.

root@s2-vd-1:/home/Administrator# cat /proc/partitions
major minor  #blocks  name
   8       16   20971520 sdb
   8        0   83886080 sda
   8        1     975872 sda1
   8        2          1 sda2
   8        5   82907136 sda5
 252        0   31248384 dm-0
 252        1    9764864 dm-1
 252        2   29294592 dm-2
 252        3   12595200 dm-3

Note:- Switch to sudo user using  "sudo su" for this procedure.


Now to use the newly added disk we need to create partitions from the raw disk which is SDB. We can use the whole 20G partition for extending one LV which we doing here for Demo however we can have multiple partitions as well and extend other LV's using those partitions.

To Create a partition fdisk cmd is used where we select n for new partition and p for primary partitions. At this point we can define the size of the disk we are going to use and write the changes.

root@s2-vd-1:/home/Administrator# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5b930cc8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n

Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended

Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039


Command (m for help): w

The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Once the changes are written we should see a new partition is created as /dev/sdb1 using lsblk command.


We will have to initialize physical volume for use by LVM. To initialize physical volume pvcreate command can be used and to display PV "sudo pvdisplay" command can be used.

root@s2-vd-1:/home/Administrator# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created



We need to add additional physical volumes to an existing volume group which will increases a volume group's capacity by adding one or more free physical volumes. We already have a VG created in director called system which can be seen using "vgdisplay" command.

To extend the VG we need to use "vgextend <VolumeGroupName> <PhysicalDevicePath>" cmd as shown below. VolumeGroupName  is system and PhysicalDevicePath is /dev/sdb1 in our example.

root@s2-vd-1:/home/Administrator# vgextend system /dev/sdb1
  Volume group "system" successfully extended

root@s2-vd-1:/home/Administrator# vgdisplay
  --- Volume group ---
  VG Name               system
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  9
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                3
  Act PV                1
  VG Size               87.05 GiB
  PE Size               4.00 MiB
  Total PE              22286
  Alloc PE / Size       22286 / 87.05 GiB
  Free  PE / Size       0 / 0
  VG UUID               GttHef-fdbk-hsrQ-AUlW-HlqS-FUs5-UG38Th



Now we are at the final step of extending logical volume /var using lvextend command which will add the free extents to our LV.


root@s2-vd-1:/home/Administrator# lvextend -l +100%FREE -r /dev/system/var
  Extending logical volume var to 47.93 GiB
  Logical volume var successfully resized

resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/system-var is mounted on /var; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/mapper/system-var is now 12565504 blocks long.




This is the final output where we can see an additional 20 GB has been added to var


root@s2-vd-1:/home/Administrator# sudo lvs
  LV     VG     Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  opt    system -wi-ao---  9.31g
  root   system -wi-ao--- 12.01g
  swap_1 system -wi-ao--- 29.80g
  var    system -wi-ao--- 47.93g

Similarly, we can also extend opt and root if needed.