• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

Linux LVM – Re-sizing the Logical Volume

August 14, 2013 By Cloud_Devops 6 Comments

In LVM, logical volumes size can be increased or decreased depends on our needs. Logical volume can be shirked/reduced using “lvreduce” command but this will not reduce the filesystem. You need to reduce the filesystem before reducing the logical volume. Logical volume can be extended/increased using “lvextend” command.Once you have extended the logical volume ,then you need to increase the filesystem to the see new space on the mount points.
 
Most of the Linux/Unix beginners will confuse with term ‘volume’ and ‘filesystem’. Volume is a raw partition like a physical disk.In a order to store data on volume,you need a filesystems on that.(Ex:ext2,ext3,ext4…etc..)


1.Extending the Logical Volume size

Logical volumes can be increased on fly without un-mounting the filesystem. Here we will see how to increase the linear filesystem and volume on Redhat Linux 6.



1.Check the volume group free space before proceeding to the volume expansion.

[root@mylinz ~]# vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  uavg        3   1   0 wz--n-  5.99g 5.89g
  vg_mylinz   1   2   0 wz--n- 19.51g    0
[root@mylinz ~]#
#

From the above output ,we can see volume group “uavg” has 5.89GB free space. If you need more space for volume ,please extend the volume group by adding new LUNS or DISKS.


2.We are planning to extend volume “lvol0” from uavg volumegroup. 

[root@mylinz ~]# lvs
  LV      VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lvol0   uavg      -wi-ao 100.00m
  lv_root vg_mylinz -wi-ao  16.54g
  lv_swap vg_mylinz -wi-ao   2.97g
[root@mylinz ~]# df -h /vol1/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/uavg-lvol0
                       97M  5.6M   87M   7% /vol1
[root@mylinz ~]# lvdisplay /dev/uavg/lvol0
  --- Logical volume ---
  LV Name                /dev/uavg/lvol0
  VG Name                uavg
  LV UUID                0rtjKO-3GdM-CeOf-CY8m-fZgH-wjgu-kJivtd
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.00 MiB
  Current LE             25
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

[root@mylinz ~]#

 

3.Extend the logical volume by 100MB.

[root@mylinz ~]# lvextend -L +100M /dev/uavg/lvol0
  Extending logical volume lvol0 to 200.00 MiB
  Logical volume lvol0 successfully resized
[root@mylinz ~]# lvdisplay /dev/uavg/lvol0
  --- Logical volume ---
  LV Name                /dev/uavg/lvol0
  VG Name                uavg
  LV UUID                0rtjKO-3GdM-CeOf-CY8m-fZgH-wjgu-kJivtd
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 MiB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

[root@mylinz ~]#


4.Check the mountpoint “/vol1” .The new space is not be reflected there because,Since you didn’t resize the filesystem.

[root@mylinz ~]# df -h /vol1/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/uavg-lvol0
                       97M  5.6M   87M   7% /vol1
[root@mylinz ~]#


5.Increase the filesystem.

[root@mylinz ~]# resize2fs /dev/uavg/lvol0
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/uavg/lvol0 is mounted on /vol1; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/uavg/lvol0 to 204800 (1k) blocks.
The filesystem on /dev/uavg/lvol0 is now 204800 blocks long.

[root@mylinz ~]#


6.Check the mountpoint now.

[root@mylinz ~]# df -h /vol1
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/uavg-lvol0
                      194M  5.6M  179M   3% /vol1
[root@mylinz ~]#

Wow..We have successfully increased the vol1 from 100MB to 200MB.
The same way you can increase any type of volume layouts.

2.Reducing the Logical Volume size

Volumes can’t be  reduced on the fly.To reduce the volume ,
1. umount the filesystem
2. Reduce the filesystem size 
3. Reduce the logical volume
4. Mount the volume .



Here we will see how to reduce the volume “lvol0” which is part of volume group “uavg” .

1.List he volume information.

[root@mylinz ~]# lvs
  LV      VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lvol0   uavg      -wi-ao 200.00m
  lv_root vg_mylinz -wi-ao  16.54g
  lv_swap vg_mylinz -wi-ao   2.97g
[root@mylinz ~]# lvdisplay /dev/uavg/lvol0
  --- Logical volume ---
  LV Name                /dev/uavg/lvol0
  VG Name                uavg
  LV UUID                0rtjKO-3GdM-CeOf-CY8m-fZgH-wjgu-kJivtd
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 MiB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

[root@mylinz ~]# df -h /vol1
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/uavg-lvol0
                      194M  5.6M  179M   3% /vol1
[root@mylinz ~]#


2.un-mount the filesystem.

[root@mylinz ~]# umount /vol1
[root@mylinz ~]#


3.Reduce the filesystem by 100MB. The current filesystem size is 200MB.
Option 100MB – Final size of the volume.

[root@mylinz ~]# resize2fs /dev/uavg/lvol0 100M
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/uavg/lvol0' first.
[root@mylinz ~]#

“resize2fs” required to check the filesystem consistency before reduce the FS.

[root@mylinz ~]# e2fsck -f /dev/uavg/lvol0
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/uavg/lvol0: 11/49400 files (9.1% non-contiguous), 11884/204800 blocks
[root@mylinz ~]# resize2fs /dev/uavg/lvol0 100M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/uavg/lvol0 to 102400 (1k) blocks.
The filesystem on /dev/uavg/lvol0 is now 102400 blocks long.
[root@mylinz ~]#

We have successfully reduced  the filesystem to 100MB.

4.De-activate the volume.

[root@mylinz ~]# lvchange -an /dev/uavg/lvol0


5.Reduce the volume. “-L” – Final size of the volume.
Here i am giving volume final size as 104MB. So that  volume may have some room and  won’t touch the filesystem part.The extra 4MB can be recovered using resize2fs. Its up to you how you want to proceed.
Note:You can also give 100MB. For safer side, its better to give some extra space on the volume level.
Having good backup is recommeded before proceeding to volume resize.

[root@mylinz ~]# lvreduce -L 104M /dev/uavg/lvol0
Do you really want to reduce lvol0? [y/n]: y
  Reducing logical volume lvol0 to 104.00 MiB
  Logical volume lvol0 successfully resized
[root@mylinz ~]#



6.Activate the volume and Mount it.

[root@mylinz ~]# lvchange -ay /dev/uavg/lvol0
[root@mylinz ~]# mount -t ext4 /dev/uavg/lvol0 /vol1
[root@mylinz ~]# df -h /vol1
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/uavg-lvol0
                       97M  5.6M   87M   6% /vol1
[root@mylinz ~]#


7.After shrinking the volume size, if you want to remove the physical disks which is not used in volume group,you can remove it using vgreduce command. 

Hope now you are familiar with volume re-sizing operation on Logical volume manager.

Please leave a comment if you have any doubt . I will get back to you .

Thank you for reading this article.

Filed Under: LVM, LVM Tutorials

Reader Interactions

Comments

  1. Rajender Sharma says

    May 4, 2020 at 12:50 pm

    explanation very good .

    Reply
  2. sai says

    June 9, 2019 at 6:45 pm

    good explanation….. it was very clearly nice article it was very helpful

    Reply
  3. Arun Takru says

    September 16, 2016 at 5:28 pm

    while increasing the filesystem “resize2fs /dev/uavg/lvol0”
    where it shows that user wants 200MB ?

    Reply
  4. PC says

    June 2, 2016 at 4:55 pm

    How do we know that the reduced size is from which disk present in the volume group?

    Reply
  5. arun says

    February 27, 2015 at 3:18 pm

    Thanks. How to reduce lv size using lvresize command?

    Reply
  6. Sheikh Faisal says

    January 9, 2014 at 10:14 pm

    excellent

    Reply

Leave a Reply Cancel reply

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

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version