Adding a Physical Volume to a Logical Volume Group and Extending the filesystem

ADDING A PHYSICAL VOLUME TO A LOGICAL VOLUME

Then extend the volume

If you want to add a disk without turning off the VM, after adding the disk through the VI Client, run this on the Linux VM:

ls /sys/class/scsi_host

You will see something like this:

ls /sys/class/scsi_host
host0  host1  host2

Then run the below command for each of the hosts – subsitute the # for the 0, 1 and 2.

echo "- - -" > /sys/class/scsi_host/host#/scan

Use fdisk -l  to confirm that the new disk is visible to the operating system.

#Add the physical disk, in our case /dev/sda3. It is 24G and the current disk is also 24G.

#lvdisplay / df -h / fdisk -l will give you all the necessary information you require.

#In our case, the Logical Volume name is antares, the path is /dev/mapper/antares-root.

#First prepare the physical disk to be enabled so it can join the Logical Volume.

pvcreate /dev/sda3

#Next, extend the volume group to include the newly enabled disk.

vgextend antares /dev/sda3

#Now resize the underlying physical disks from 24G to 48G.

lvextend -L48G /dev/mapper/antares-root

#Finally, resize so the filesystem can recognize the newly extended space

resize2fs /dev/mapper/antares-root

#N.B. if the filesystem is XFS, you will need to run the following command instead

xfs_growfs /dev/mapper/antares-root

 

 

Confirm it has extended Properly

#Now do a df -h to ensure that the filesystem can see the changes. In our case it went from:

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/antares-root
24G 8.3G 14G 38% /
tmpfs 994M 0 994M 0% /lib/init/rw
varrun 994M 96K 994M 1% /var/run
varlock 994M 0 994M 0% /var/lock
udev 994M 152K 994M 1% /dev
tmpfs 994M 0 994M 0% /dev/shm
lrm 994M 2.5M 992M 1% /lib/modules/2.6.28-17-server/volatile
/dev/sda5 228M 83M 134M 39% /boot

#to this

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/antares-root
48G 8.3G 37G 38% /
tmpfs 994M 0 994M 0% /lib/init/rw
varrun 994M 96K 994M 1% /var/run
varlock 994M 0 994M 0% /var/lock
udev 994M 152K 994M 1% /dev
tmpfs 994M 0 994M 0% /dev/shm
lrm 994M 2.5M 992M 1% /lib/modules/2.6.28-17-server/volatile
/dev/sda5 228M 83M 134M 39% /boot