Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I had a Linux LVM volume that was about 400 GB. I shrank it to 217 GB following the steps below.

umount /local
e2fsck -f /dev/mapper/vg00-lvol2
resize2fs /dev/mapper/vg00-lvol2 217G
lvresize -L 217G /dev/mapper/vg00-lvol2
lvdisplay /dev/mapper/vg00-lvol2
mount /local

And then I resized the physical volume to 260 GB with pvresize. If I do pvdisplay and lvdisplay now, I get:

lvm> pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               vg00
  PV Size               260.00 GB / not usable 31.81 MB
  Allocatable           yes 
  PE Size (KByte)       32768
  Total PE              8319
  Free PE               250
  Allocated PE          8069
  PV UUID               6itmL0-3HAd-tmhA-a3u3-ketO-H7OO-MahFc7

lvm> lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg00/lvol1
  VG Name                vg00
  LV UUID                JFATdC-lqxK-wsBc-VgL1-33Xv-PUfb-Y28fk2
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                35.16 GB
  Current LE             1125
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/vg00/lvol2
  VG Name                vg00
  LV UUID                F81eoe-xokM-Jqwr-NXND-VujX-BwN6-Kh0zZa
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                217.00 GB
  Current LE             6944
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

How can I revert these steps? That is, to resize the physical volume and the logical volume back to their original sizes.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can:

# this will expand the PV to max size available (e.g. full disk/disks size/sizes
# (as PV can occupy many disks))
pvresize /dev/sda3
# the -r switch does resize2fs for you automatically
lvresize -L 400G -r /dev/mapper/vg00-lvol2

However I can't find in the man pages how to resize LV to VG size limit, so giving it 400G may say that the new LV size is larger than VG size. So put 399G in here etc.

By the way: You can use lvresize -L switch with + and - flags, like lvresize -L+30GB <lvname>, the LV will be resized to actual_size+30GB.

share|improve this answer
    
Thanks. I finally did it like this: pvresize /dev/sda3, lvresize -l +100%FREE /dev/sda3, umount /local, e2fsck -f /dev/mapper/vg00-lvol2, resize2fs /dev/mapper/vg00-lvol2, mount /local. Both pvresize and resize2fs seem to expand to the maximum free space available. –  rturrado Nov 3 '11 at 20:05
    
Good :) I didn't know about 100%FREE parameter. btw you don't have to umount the drive for enlarging (if it is xfs/jfs/ext3-4/etc.) (but of course you have to do it for fsck) –  NoICE Nov 3 '11 at 20:09
    
I was requested to do an e2fsck before the resize2fs. –  rturrado Nov 3 '11 at 20:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.