October 9, 2015

CentOS LVM Resize

Since the release of CentOS 5.5 we noticed that the default CentOS install assigns a considerable amount of its available storage space to Swap. If you don’t catch this during the installation don’t worry, Logical Volume Manager or LVM will rectify this post install.

LVM is a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices, in particular large ones. The term “volume” refers to a disk drive or partition thereof.

Before we start just some general housekeeping. The XEN virtual CentOS 5.5 server (base install) in this tutorial was assigned 10GB of storage with the default partitioning layout.

Let check the amount of disk space available on the file system.

Let see the attributes of the logical volumes like size, read/write status, snapshot information

Let’s begin but first turning off swap on the Swap Logical Volume

Once swap is off let’s take the disk space we require.

Now let’s add what we removed to the main Logical Volume.

Resize the File System

Rebuild the swap partition.

Turn swap on.

Let’s check the amount of disk space available and LVM attributes to see if our changes took effect.

  • Anonymous Coward

    Anyone using default partitioning doesn’t really care about the amount of allocated swap space. Anyone using the defaults is surely just building a throw away unit anyway.

    This posting would have much more value if you applied it in the general case of using LVM for real space issues.

  • James Tanaglia

    Yay! Excellent post for a quick space recovery. Thanks!

  • ventura10

    Thanks man, you saved my day!

  • Pgpresto

    Thank you so much for the accurate and detailed post. Very helpful!!

  • Thalamus

    NICE !!

  • Денис Пищухин


  • Richy

    It’s very helpful

  • Aldopraherda

    thanks. you saved my space

  • Halil-Cem Gürsoy


  • Ron Cormier

    Exactly what I need to extend my volume …

  • Srinivas_0618

    Simple steps and nice thanks for the explanation post. SRINIVAS

  • Test

    We saved a life

  • Facundor

    You saved my live! 

    Thanks a lot!

  • Fhouel

    Excellent … Thanks a lot !

  • samantha

    wow. thank you so much. we’re doing small installs in one of our labs and we were shocked to find the default swap space was nearly half the size of the root partitions. This saved us from starting back at the beginning of creating our clone images. Thank you!!

  • centosese

    Great. I have been looking for way to resize the “lv” partition… Thanks

  • Sandip

    Excellent! Very clear and concise. Just what I’ve been looking for.