Extending LVM Partition and Resizing Filesystem

You can easily resize your storage, by expanding an LVM volume involves two main steps: extending the logical volume and then resizing the file system to fit the additional space.

Before making changes to your logical volumes and filesystem, it's highly recommended that you backup any important data.

1) Important basic concepts:

 

  1. Physical Volumes: Hold raw storage divided into physical storage devices, like /dev/sda or /dev/sdb, which are treated as raw storage for the LVM layer.

  2. Volume Groups (VG): These aggregate multiple PVs and can be found with the vgdisplay command, showing properties including the VG name, which you'll use to reference the group. In general these provide the tools to add multiple Physical Volumes into one storage pool, providing an abstraction layer over physical storage.

  3. Logical Volumes (LV): Partition-like spaces created from VG. These are typically referenced as /dev/vg1/lv1, where vgname is your volume group name and lvname is your logical volume name. Each LV is a device file that can be formatted with a file system.

  4. File Systems: Methods for data storage/retrieval. Once a LV is formatted with a file system (like ext4 or xfs), it's mounted to a mount point in the filesystem hierarchy, e.g., /mnt/volume.

 

2) Volume Group


You can confirm that the Volume Group has already enough space available, by executing:

$ sudo vgdisplay

Which should return: Free PE / Size with enough space. In case it does not, the VG will need to be resized.


Keep in mind the VG Name

3) Expand Logical volume

Now that we have confirmed there is space free within the volume group,

Next we will use the command below to see logical volumes in detail. It will also show the volume group that the logical volume is a member of, check for the VG Name, same as above, so no mistakes are made.

$ sudo lvdisplay



Expanding the Logical Volume can be done in different ways, here are two examples:



$ sudo lvextend -L +10G /dev/vgname/lvname

 

$ sudo lvextend -l +100%FREE /dev/vgname/lvname

 

 

4) Resize File System

Now that the logical volume has been extended, we can resize the file system.

For ext

 

$ sudo resize2fs /dev/vgname/lvname

 

For XFS

 

$ sudo xfs_growfs /dev/vgname/lvname

 

5) Verify

 

$ df -hT

 

 

  • 1 gebruikers vonden dit artikel nuttig
Was dit antwoord nuttig?

Gerelateerde artikelen

Remove disc from sources.list

Want to update Debian but just recive this error?: Media change: please insert the disc...

Root user on Ubuntu / Debian

On standard Ubuntu and Debian does not offer a root user via ssh (unless you activate him), you...

Long password

For security reasons we always recommend to set strong and long passwords.But we also advise to...

Speedtest

Step-by-step guide sudo apt-get install python-pip sudo pip install speedtest-cli...

VPS Upgrade options/prices

 + 2GB RAM upgrade  = 4 eur/month (maximum RAM allocation 6GB) + 1 CPU-core upgrade = 5 eur/month...