With ever more demand for storage it is inevitable that servers at some point will need additional storage devices. This is even more the case with virtual machines, as they tend to be deployed with far less initial storage space than contemparery physical drives are capable of.

 

Perhaps more as a reminder for myself what follows are the steps for adding an additional space to a linux vm (CentOS) using lvm while the machine remains online. For the following excerise I'm assuming all physical extents are used and that the existing virtual harddisk is not going to be extended in vmware. There are pro's and con's to either extend harddrives or adding a virtual disk, but I'm not going into that.

The first thing is to add an additional harddisk in vmWare, chose whatever size you want to add, I'm adding 10GB.

Once that is done, we need to make it visible in the OS

First list the scsi_hosts with

ls /sys/class/scsi_host

 

For every host you've found do

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

 

It doesn't give any output but with

fdisk -l

 

the new drive should show up.

Next create a physical volume on the disk you've found with

pvcreate /dev/sdX

 

and add this physical volume to the volume group with

vgextend [vg_name] /dev/sdX

 

The next step is to extend the logical volume, you can extend it to any size you want with the option -L +[size], but you'll probably want to use all available space which can be done with

lvextend -l +100%FREE /dev/[vg_name]/[lv_name]

 

At last we can resize the filesystem with

resize2fs /dev/[vg_name]/[lv_name]

 

Now a df -h will show the new filesystem size

Share this post

Design by JoomlaSaver