Resizing Logical Volume (LVM) on ext3 – openSUSE SLES RedHat – Extend Shrink Reduce
There are a few steps you have to take to resize a partition. First, you have to resize the filesystem (be sure to do this before you reduce the lv, as that could cause data loss).
In this instance I’ll be resizing a mount location at /app. If you want to shrink the /home partition make sure you go into runlvl 3 (sudo init 3) and get out of the /home directory (cd /).
To shrink the file system lets unmount it by running:
First run a check on the file system:
note: you can find the volume group name, or logical volume name you can use vgscan and lvscan (both are located in /sbin/)
Now lets shrink the ext3 partition:
note: 10G is the NEW size that you want it to be
Once those are completed, you can finally shrink the Logical Volume (isn’t this what we wanted in the first place?), to do this do:
note: Use the same output you defined in the resize2fs command.
Here are some extra usages of lvreduce via the man page
Reduce or set the logical volume size in units of logical extents. With the – sign the value will be subtracted from the logical volume’s actual size and without it the will be taken as an
absolute size. The number can also be expressed as a percentage of the total space in the Volume Group with the suffix %VG or relative to the existing size of the Logical Volume with the suf-
fix %LV or as a percentage of the remaining free space in the Volume Group with the suffix %FREE.
-L, –size [-]LogicalVolumeSize[kKmMgGtTpPeE]
Reduce or set the logical volume size in units of megabyte by default. A size suffix of k for kilobyte, m for megabyte, g for gigabytes, t for terabytes, p for petabytes or e for exabytes is
optional. With the – sign the value will be subtracted from the logical volume’s actual size and without it it will be taken as an absolute size.
Lets remount our partition and jump for joy:
note: If this mount point is defined in /etc/fstab, you can remount via sudo mount -a (this will mount everything in /etc/fstab).
To extend a Logical Volume (this can be done in real time and no un-mounting is required)
First lets extend the logical volume
Here are more usages of lvextend from the man pages:
Extend or set the logical volume size in units of logical extents. With the + sign the value is added to the actual size of the logical volume and without it, the value is taken as an absolute
one. The number can also be expressed as a percentage of the total space in the Volume Group with the suffix %VG, relative to the existing size of the Logical Volume with the suffix %LV, of
the remaining free space for the specified PhysicalVolume(s) with the suffix %PVS, or as a percentage of the remaining free space in the Volume Group with the suffix %FREE.
-L, –size [+]LogicalVolumeSize[kKmMgGtTpPeE]
Extend or set the logical volume size in units of megabytes. A size suffix of M for megabytes, G for gigabytes, T for terabytes, P for petabytes or E for exabytes is optional. With the + sign
the value is added to the actual size of the logical volume and without it, the value is taken as an absolute one.
-i, –stripes Stripes
Gives the number of stripes for the extension. Not applicable to LVs using the original metadata LVM format, which must use a single value throughout.
-I, –stripesize StripeSize
Gives the number of kilobytes for the granularity of the stripes. Not applicable to LVs using the original metadata LVM format, which must use a single value throughout.
StripeSize must be 2^n (n = 2 to 9)
To extend the filesystem do
note: this can be done in real time
Bonus:
If you wanted this space for an existing logical volume, you can run lvextend -L XXG /dev/volumegroup/logicalvolume.
Note: XX is the space you took away from the other reduced partition.







3 Comments
Hi,
I see that you only mention about reducing the lv.
I tried to extend one of my lv. and using lvdisplay, I can see that the size already extend. (from 250GB t0 390GB). But, using df I can only see 250GB (the original size). What is wrong? and what should I do?
This is out put from df -h
/dev/mapper/VolGroup00-LogVol06
250G 231G 7.2G 97% /oracle
and this is output from lvdisplay
— Logical volume —
LV Name /dev/VolGroup00/LogVol06
VG Name VolGroup00
LV UUID 1AVRAH-nZaV-Vvia-26Ev-REdh-T0KT-KPBNsS
LV Write Access read/write
LV Status available
# open 1
LV Size 390.66 GB
Current LE 12501
Segments 3
Allocation inherit
Read ahead sectors 0
Block device 253:2
Thanks,
Dapid Candra
@Dapid Candra
Thanks for the comment. If you’ve already ran lvextend then what you’ll want to do is do an ext2online /dev/mapper/VolGroup00-LogVol06
Which will extend the actual filesystem to the new size which is indicated via the lvdisplay.
Let me know if you have any questions.
Your tips is the exact solution for the problem. I just run it and after finish df result show the size already 385GB.
There is discrepancy between lvdisplay size information and df, but comparing to other mount points (other lvs), the difference is common.
Thank you Sir.
2 Trackbacks
[...] unknown: [...]
Shrink ext3 Partitions (Centos 5/RHEL 5 way)…
NOTE : This article come with ABSOLUTELY NO WARRANTY about any data loss. Rember to do a FULL BACKUP of your filesystem every time you need to expand/shrink them. Here you are an how-to for shrink ext3 partitions. NOTE : You can’t perform on-line…