# LVM - extend the volume

To extend the volume, we have to attach new physical (virtual) disk on hypervisor.


## Preparations

We need to understand which disk need to be extended:
In my case it is a root which is full.
```bash
df -h
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/bsf3mBhiQiJ1TY7B-image-1753066918364.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/bsf3mBhiQiJ1TY7B-image-1753066918364.png)

and verify it is LVM
```bash
lsblk
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/nUynxOxAeW14fYNp-image-1753067074668.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/nUynxOxAeW14fYNp-image-1753067074668.png)

After adding the disk, it should appear in the list:
```bash
lsblk
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/QPac3deDK85EUCgl-image-1753066783696.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/QPac3deDK85EUCgl-image-1753066783696.png)

Let's note which file system in use: 'XFS' or 'ext4', will be needed later..
```bash
lsblk -f
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/PxDNlEAdU2fhI95P-image-1753067304566.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/PxDNlEAdU2fhI95P-image-1753067304566.png)

We are good to go, prepare for activities. Replace your values for variables ```dev``` and ```fs``` with correct ones. Subtract ```0.1``` from partition size:
```bash
export dev="/dev/sdc"
```

Disk need to be marked as a "Physical Volume" to be able to join the "volume group" and list:
```bash
pvcreate ${dev}
pvscan
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/hyE3fOSAKf0cZI0u-image-1753068015252.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/hyE3fOSAKf0cZI0u-image-1753068015252.png)

First, let's define, which 'volume group' need to be extended
```bash
vgscan
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/MzJJBqsLFMjrCU12-image-1753068155973.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/MzJJBqsLFMjrCU12-image-1753068155973.png)


In my case, it is ```ol_vbox```. Let's define it:
```bash
export vg="ol_vbox"
```

Let add "new Physical Volume" to the "Virtual Group":
```bash
echo ${vg}
echo ${dev}
vgextend ${vg} ${dev}
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/AL0nogwrCgajX6lj-image-1753068416197.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/AL0nogwrCgajX6lj-image-1753068416197.png)

List Physical Volumes, new disk should be shown
```bash
pvscan
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/e8Ust92SIaqzt43V-image-1753068482983.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/e8Ust92SIaqzt43V-image-1753068482983.png)

Now it is a time to extend Logical Volume. Let's observe current ones first
```bash
lvdisplay
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/wcgWYhfgwtHnlKG7-image-1753069224318.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/wcgWYhfgwtHnlKG7-image-1753069224318.png)

In my case, "Volume Group" is linked to "Logical Volume" has path "/dev/ol_vbox/root".
Set up extension size. 
```bash
export lv="/dev/ol_vbox/root"
export size="49.9G"

```
and extend "Logical Volume"
```bash
lvextend -L +${size} ${lv}
```
[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/ZeoQqsJgcvDAV360-image-1753069308477.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/ZeoQqsJgcvDAV360-image-1753069308477.png)


Depending on which file system is in use, note current partition size, expand it and check size again:
```bash
df -h

# for "ext4"
resize2fx ${lv}

# for "xfs"
xfs_growfs ${lv}

df -h
```


[![](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/scaled-1680-/HYPgPbO0JVZcOrDZ-image-1753069443887.png)](https://storage.googleapis.com/iau-data-dox/uploads/images/gallery/2025-07/HYPgPbO0JVZcOrDZ-image-1753069443887.png)


Q.E.D.

Storage management using LVM is a logical process, once understood.