# Extending LVM in Linux: A Step-by-Step Guide


If you use LVM (Logical Volume Manager) for managing disk partitions on your Linux system, you may eventually find yourself needing more storage space. Thankfully, one of the big advantages of LVM is that it makes it easy to expand your logical volumes and increase storage capacity.

In this beginner's guide, I'll walk you through the step-by-step process of extending an LVM logical volume in Linux.

## Understanding LVM Storage

Before jumping into the how-to, let's briefly go over some LVM terminology. LVM allows you to create logical volumes that span multiple physical volumes (hard drives/partitions). This gives more flexibility compared to directly using physical partitions.

Some key terms:

- **Physical Volume (PV)** - The underlying hard drives or partitions used for LVM storage.
- **Volume Group (VG)** - A collection of physical volumes. Think of this as a storage pool.
- **Logical Volume (LV)** - A partition that is created out of the volume group pool and acts as a virtual partition for the operating system.

> Also read - [**Linux Mint vs Ubuntu: Which Linux Distro Is Better for You?**](https://developnsolve.com/linux-mint-vs-ubuntu-which-linux-distro-is-better-for-you)

## Prerequisites

Before extending a logical volume, make sure:

- You have free/unallocated space available in the related volume group. Use `vgdisplay` to verify.
- No snapshots exist for the logical volume. Delete or merge them first.
- You have appropriate permissions to edit LVM.

## Step 1: Extend the Underlying Physical Volume

If needed, use disk management tools like `fdisk` or `gparted` to grow the underlying physical partitions or disks.

For example, to grow `/dev/sda3` partition:

```plaintext
fdisk /dev/sda
> delete 3
> create new 3 with larger size
> write
> quit
```

Then resize the filesystem (assuming ext4):

```plaintext
resize2fs /dev/sda3
```

Now your physical volume has unallocated space.

## Step 2: Extend the Volume Group

Next, use `vgextend` to add the new physical storage space to the volume group:

```plaintext
vgextend dataVG /dev/sda3
```

Replace `dataVG` with your actual VG name.

Use `vgdisplay` to verify that total free space has increased.

## Step 3: Extend the Logical Volume

Finally, leverage the extra VG space to expand the logical volume:

```plaintext
lvextend -L +5G /dev/dataVG/videos
```

This extends `/dev/dataVG/videos` LV by 5 GB. Use your desired size.

## Step 4: Resize the Filesystem

Almost done! With the LV extended, the last step is to resize the filesystem to occupy the new space:

```plaintext
resize2fs /dev/dataVG/videos
```

And that's it! Your logical volume now has extra storage capacity. Use `lvdisplay` and `df -h` to verify.

> Also read - [**Making Directories Writable in Linux**](https://developnsolve.com/making-directories-writable-in-linux)

## Key Takeaways

Expanding LVM storage is straightforward once you understand the relationships between physical volumes, volume groups, and logical volumes. The key steps are:

1. Extend the underlying physical storage
2. Add the extra physical space to the volume group
3. Expand logical volume to the desired new size
4. Resize the filesystem to use the full logical volume

The flexibility of LVM enables you to easily add more storage as needed. With just a few commands, you can expand capacity without disruptions. Hopefully, this gives you a good overview of the process.

Let me know if you have any other questions.

