Comptia Linux+ LVM Shrink Size
-
Hi there,
The course video which talks about LVM shows creating, adding resizing and deleting the volumes.
What would be the procedure and commands to shrink the logical volume size?
What happens to the data if the LVM was shrunk to a smaller size? If the logical volumes has data, how do we ensure data was not lost? What would be the best practice on doing this?
-
LVM does support shrinking a volume. You would use the following option:
lvreduce --resizefs
However, it is worth pointing out that shrinking a volume is a lot riskier than extending a volume. So much so, that most paid support vendors (Red Hat, Canonical, etc) do not officially support shrinking volumes. Software like GParted make use of various hacks and cludges to make shrinking work. For example, GParted attempts to move all files to the begining of the volume, leaving all of the empty space at the end where it can be trimmed. It will not allow you to shrink the volume by an amount greater than the free space available.
The recommended best practice is that you backup the data, rebuild the volume to the desired size, and then restore the data. This causes downtime, but it is guaranteed to work.
-
Good to know. Thanks