How to resize or expand LVM

This entry was posted in Linux, Storage and tagged on June 17, 2012, by

How to resize LVM ?

Suppose we have a filesystem mounted on LVM. We need to expand the space in it. Following commands should be use to expand the filesystem without unmounting the filesystem.

  • lvextend
  • resize2fs

Following is the example

# df -ah

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              19G  5.7G   13G  32% /
proc                     0     0     0   –  /proc
sysfs                    0     0     0   –  /sys
devpts                   0     0     0   –  /dev/pts
/dev/sda1              99M   11M   83M  12% /boot
tmpfs                1013M     0 1013M   0% /dev/shm
none                     0     0     0   –  /proc/sys/fs/binfmt_misc
sunrpc                   0     0     0   –  /var/lib/nfs/rpc_pipefs
configfs                 0     0     0   –  /sys/kernel/config
nfsd                     0     0     0   –  /proc/fs/nfsd
/dev/mapper/data1-datavol
2.0G  2.0G     0 100% /applications

You can see /application is full. Now we need to resize it. It is on LVM.

First of all you need to extend the logical volume.In my case I extended upto 2 GB.

# lvextend -L +2G /dev/data1/datavol

Extending logical volume datavol to 4.00 GB
Logical volume datavol successfully resized

Next is to resize the logical volume

# resize2fs /dev/data1/datavol
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/data1/datavol is mounted on /applications; on-line resizing required
Performing an on-line resize of /dev/data1/datavol to 1048576 (4k) blocks.
The filesystem on /dev/data1/datavol is now 1048576 blocks long.

Now check if it is expanded

# df -ah
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              19G  5.7G   13G  32% /
proc                     0     0     0   –  /proc
sysfs                    0     0     0   –  /sys
devpts                   0     0     0   –  /dev/pts
/dev/sda1              99M   11M   83M  12% /boot
tmpfs                1013M     0 1013M   0% /dev/shm
none                     0     0     0   –  /proc/sys/fs/binfmt_misc
sunrpc                   0     0     0   –  /var/lib/nfs/rpc_pipefs
configfs                 0     0     0   –  /sys/kernel/config
nfsd                     0     0     0   –  /proc/fs/nfsd
/dev/mapper/data1-datavol
4.0G  2.0G  1.8G  53% /applications

You can see the applications filesystem is expanded .

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright 2017 ©Aceadmins. All rights reserved.