-   Linux - Software (
-   -   Resizing Centos (ext3/LVM) partition (

alexpacio 08-08-2007 07:06 AM

Resizing Centos (ext3/LVM) partition
How can I resize (shrinking) an ext3/LVM partition created by Centos 5's Anaconda?

brianmcgee 08-08-2007 07:33 AM

For example if you want to shrink a 100G partition to 50G:

# rsync -rv /mount/point/* /srv/backups
# umount /mount/point
# fsck.ext3 /dev/mapper/lv_lvname
# resize2fs /dev/mapper/lv_lvname 50G
# lvresize -v -L -50G /dev/vg_vgname/lv_lvname


lvresize allows you to resize a logical volume. Be careful when reducing a logical volume's size, because data in the reduced part
is lost!!! You should therefore ensure that any filesystem on the volume is shrunk first so that the extents that are to be removed
are not in use. Resizing snapshot logical volumes (see lvcreate(8) for information about creating snapshots) is supported as well.
But to change the number of copies in a mirrored logical volume use lvconvert(8).

alexpacio 08-08-2007 02:07 PM

Is it necessary to backup data before proceeding (rsync -rv /mount/point/* /srv/backups) ?

brianmcgee 08-09-2007 01:53 AM

If the data is important you should have a backup anyway. In my point of view the shrinking of a filesystem is more dangerous than extending it. For example if there is only a slight difference in how the programs calculate the parameters for the sizing you might end up with a filesystem that is truncated. In that case not only the data that was cut off is lost but there is also the possibility that you get a corrupted filesystem that may be never restored again.

Usually I shrink my filesystem more than I shrink the lvm or the actual partition. Then I extend the filesystem to the maximum possible amount.

alexpacio 08-09-2007 11:22 AM

Thank you for the fast reply.

If I have any problem I will notice them in this post...

Thank you again!

alexpacio 08-10-2007 10:34 AM

I tried to procced through the 'linux rescue' option of the centos installation cd but when i try to unmount the partition it say that I can-t do it {i tried with force option too]...Is it possible that I can't resize a LVM partition ? :cry: :cry: :cry:


brianmcgee 08-11-2007 02:39 AM

You sure can resize a LVM partition. Did you try to unmount the root partition in the rescue mode? Because the actual system wil be mounted under /mnt/sysimage/

The unmount is needed for the filesystem check. Ext3 can be resized online.

All times are GMT -5. The time now is 08:34 PM.