• We did not send an email asking for donations - please read this post.

Resize Linux storage with LVM


Staff member
Oct 27, 2011
Reaction score
You need more space on your server/desktop/etc.. This guide will help you add it to the volume you’re currently using on your system. For the sake of making this an easy-to-follow guide, we’ll assume that you already have the new drive showing in your Linux installation from fdisk, but it’s not yet usable (ie: you made it available from shared storage, you installed a new hard drive, etc..).

First, let’s see if the system can see the new storage:
# fdisk -l
Disk /dev/sdc doesn't contain a valid partition table
Note: you’ll also see information about your current drives..

First things first, create a partition on the drive using fdisk, cfdisk, etc.. toggle it type ’8e’.
# fdisk /dev/sdc
Now it should show up a little better in the fdisk -l command.

Next, create the physical volume on the new partition on the new drive:
# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
Now, find out the volume group and logical volume names on your system. Make note of these..
# vgdisplay
# lvdisplay
We’ll assume that the information is:
Volume Group: test_vg
Logical Volume: test_lv

Now, use vgextend to add your new drive to the existing volume group:
# vgextend test_vg /dev/sdc1
  Volume group "test_vg" successfully extended
You can see, by viewing ‘vgdisplay’ again, it will show you the added space:
# vgdisplay
Now, pull it across into the logical volume:
# lvextend -l +100%FREE /dev/test_vg/test_lv
  Extending logical volume test_lv to 6.88 TiB
  Logical volume test_lv successfully resized
You’re almost home free – now, vgdisplay shows the correct info and so does lvdisplay – but a simple df -h still shows the filesystem size has not changed. Let’s tell the filesystem to stretch out across the full logical volume:
# resize2fs /dev/test_vg/test_lv
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/test_vg/test_lv is mounted on /TEST; on-line resizing required
old desc_blocks = 347, new_desc_blocks = 441
Performing an on-line resize of /dev/test_vg/test_lv to 1848109056 (4k) blocks.
The filesystem on /dev/test_vg/test_lv is now 1848109056 blocks long.
If you're using xfs (Centos 7 likes to use xfs by default), you won't be able to use resize2fs since that works with ext2, ext3, ext4.. you'll want to install xfsprogs:
yum install xfsprogs
Then grow it with:
xfs_growfs /dev/test_vg/test_lv

And to see how it worked out:
# df -h
Filesystem  Size  Used Avail Use% Mounted on
/dev/mapper/test_vg-test_lv  6.8T  4.9T  1.9T  73% /TEST
It worked!
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online