This short tutorial shows how to resize an LVM logical volume.
WARNING: Do not reduce the size of an active logical volume. It is the easiest way to lose you data. Recovery is possible, but it can be an involved process. Use this just as a guide on how to grow an LVM logical volume.
The screenshots you see in this tutorial where actually taken from my main desktop computer, which is running Fedora 20 KDE. And I had to perform the operation on it after an attempt to install a software failed with the error message shown in the first screenshot below.
This was the same operation I had to preform on the same computer about six months ago while also attempting to install an application. I documented that on the forum at How to resize an LVM logical volume. The error message just means that the root logical volume does not have enough disk space left for the installation to take place.
Recall that on a default installation of Fedora, where LVM is used as the partitioning scheme, three LVM logical volumes are created – root, home and Swap. On my desktop, which has a 2 TB hard drive, I allocated 15 GB to the /root logical volume, 2 GB to the Swap logical volume and the rest to the /home logical volume. The output of <strong>df -h</strong>
showed that just 228 MB of free disk space was left on the /root logical volume, and that the /home logical volume still has lots of space left. Since I do not have another disk attached to the computer, and the Swap logical volume is down to just 1 GB of disk space, the only place to grab disk space from is the /home logical volume.
Resizing an LVM volume is a simple, 2-step operation – 1. Free up space from an existing logical volume or any where on the computer where you have free disk space. 2. Use the freed space to extend or grow the target logical volume. This screenshot shows the output of <strong>lvdisplay</strong>
for the logical volumes that will be involved in the operation. For both logical volumes, note the LV Size line. Consider this screenshot the before screenshot.
This screenshot shows the two commands used for the operation. The first command was used to reduce the /home logical volume by 30 GB, while the second command used that 30 GB to extend or grow the /root logical volume by the same amount, all while the file system was online.
This is the after output of <strong>lvdisplay</strong>
. See the new sizes in the LV Size lines?
And this is the after shot of the output of <strong>df -h</strong>
.