====== Ubuntu - LVM - Increase the size of an LVM logical volume ====== To increase the size of an existing LVM logical volume **WARNING**: Be aware that extending a logical volume does not by itself let you to store more files in a filesystem located on that volume. If that is your aim then you will need to: * increase the size of the underlying block device (the logical volume), then * increase the size of the filesystem to fill the block device. These instructions cover the first step only. The method for the second step will depend on the type of filesystem (and in some cases there will be no practicable method). See below for further information. A logical volume can be extended using the **lvextend** command. You can specify either the amount by which you want to increase the size of the volume: lvextend --size +40G /dev/vg01/foo or the final size that you want to achieve: lvextend --size 120G /dev/vg01/foo If successful you should see a response of the form: Extending logical volume foo to 8.00 GB Logical volume foo successfully resized ---- ===== Testing ===== Verify the new size of the logical volume using the **lvdisplay** command: lvdisplay /dev/vg01/foo This should give a response of the form: --- Logical volume --- LV Name /dev/vg01/foo VG Name vg0 LV UUID w2q9ZN-hKnN-CLGf-6Z5g-e1QZ-DCKX-1DYZvR LV Write Access read/write LV Status available # open 0 LV Size 120.00 GB Current LE 30720 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:85 You should not at this stage expect to see any increase in the amount of usable space within whatever filesystem located on the logical volume, for example, as reported by the **df** command: it is only the size of the underlying block device that has been changed. ---- ===== Next steps ===== If the logical volume contains a filesystem then you will probably now want to extend it to fill the newly available space. Filesystems that can be extended include ext2, ext3, ext4, jfs, reiserfs and xfs. See: * Increase the size of an ext2, ext3 or ext4 filesystem. Some filesystems cannot be extended, either because their design makes this impracticable or because the necessary software has not been written. In that case your only option is to move the files somewhere else, then recreate the filesystem, then move the files back. ---- ===== Troubleshooting ===== * [[Ubuntu:LVM:Troubleshooting LVM|Troubleshooting LVM]] ===== Alternatives ===== ==== lvresize ==== An alternative to **lvextend** is to use the **lvresize** command: lvresize --size +40G /dev/vg01/foo or: lvresize --size 120G /dev/vg01/foo The difference is that **lvextend** can only increase the size of a volume, whereas **lvresize** can increase or reduce it. This makes lvresize more powerful but more dangerous. If you accidentally reduce the size of a volume without first reducing the size of the filesystem contained within it then the filesystem is likely to be damaged irreparably. For scenarios similar to the one described here, lvextend is recommended because mistakes of this type are not then possible. ---- ===== See also ===== * [[Ubuntu:Filesystem:Increase the size of an ext2, ext3 or ext4 filesystem|Increase the size of an ext2, ext3 or ext4 filesystem]] * [[Ubuntu:Filesystem:Reduce the size of an ext2, ext3 or ext4 filesystem|Reduce the size of an ext2, ext3 or ext4 filesystem]] * [[Ubuntu:LVM:Reduce the size of an LVM logical volume|Reduce the size of an LVM logical volume]] * [[Ubuntu:LVM:Increase the capacity of an LVM volume group|Increase the capacity of an LVM volume group]] * [[Ubuntu:LVM:Replace one of the physical volumes in an LVM volume group|Replace one of the physical volumes in an LVM volume group]]