How to extend the existing LVM or add disk to LVM.
ScaleArc uses logical volumes to mount the "/root" and "/data" volumes.
In case we have a disk shortage and we need to expand the disk, we can use the LVM to increase the size of /data or /root.
This process is extremely easy to do with LVM as it can be done on the fly with no downtime needed, you can perform it on a mounted volume without interruption.
Before working through the resizing process it’s important you first understand some basic concepts around physical volumes, volume groups, logical volumes, and the file system.
- Physical Volume (PV): This can be created on a whole physical disk (think /dev/sda) or a Linux partition.
- Volume Group (VG): This is made up of at least one or more physical volumes.
- Logical Volume (LV): This is sometimes referred to as the partition, it sits within a volume group and has a file system written to it.
- File System: A file system such as ext4 will be on the logical volume.
The procedure to extend the LVM is as follows:
- In order to increase the size of a logical volume, the volume group that it is in must have free space available.
- To view the free space of your volume group, run vgdisplay command as shown below and look at the “Free PE / Size” field.
- If there is free storage available we can expand the LVM using the following command
# lvextend -L<Size>G <Volume Group Path>
- If there are not much free space available in Physical Volume and Volume group.
- We can’t extend the lvm size, for extending we need to add one Physical volume (PV).
- Then we have to extend the volume group by extending the Volume group (VG).
Step 1: Add a New physical disk and create a partition:
- We will get enough space to extend the Logical volume size. So first we are going to add one physical volume.
- To add a physical volume we need to add disk additional storage to ScaleArc Instance.
- Use the following commands to Scan the new device added:
- To detect a new hard drive attached you need to first get your host bus number used using command
# grep mpt /sys/class/scsi_host/host?/proc_name
- You should get a output like below
# echo "- - -" > /sys/class/scsi_host/host2/scan
- So as you see your host2 is the relevant fields where you need to reset the storage buffer values. Run the below command
- Once done verify if you can see the new hard drive "/dev/sdc"
- For adding a new PV we have to use fdisk to create the LVM partition on the storage.
- To Create new partition Press n.
- Choose primary partition use p.
- Choose which number of partition to be selected to create the primary partition.
- Press 1 if no other partition is created on the disk.
- Change the type using t.
- Type 8e to change the partition type to Linux LVM.
- Use p to print the create partition
- Press w to write the changes.
- Verify if the new partition is visible by "fdisk /dev/sdc"
- If the partition is not visible in "/dev/" run the command partprobe to make the computer rescan the disk for partitions.
- If the device is still not listed, reboot the instance. (Rarely Needed)
- Now the device can be seen listed under /dev/ add the partition to the Volume group
$ vgextend scalearc /dev/sdc2
- Verify if the device is displayed under Volume group
- Extended the Logical Volume "data" (No need to unmount the /data volume)
$ lvextend /dev/scalearc/data /dev/sdc2
- Verify if the Volume is extended
- Resize the File System on LVM "lv_data"
$ resize2fs /dev/vg_data/lv_data
- Make sure the /data is expanded.
$ df -ah
If you are experiencing issues with ScaleArc or with any of it's features, please contact ScaleArc Support. We are available 24x7 by phone at 855 800 7225 or +1 408 412 7315. For general support inquiries, you can also e-mail us at email@example.com.
2901 Tasman Drive Santa Clara, CA 95054 | Email: firstname.lastname@example.org