Can I lvreduce after lvextend without losing the ext4 partition inside it?

Posted by DrSAR on Server Fault See other posts from Server Fault or by DrSAR
Published on 2012-10-24T06:20:12Z Indexed on 2012/10/24 23:03 UTC
Read the original article Hit count: 142

Filed under:
|
|

In a botched attempt to move my root partition from one disk to another I have done the following:

  • added new disk
  • partitioned it with parted (part #3 is now almost totally filling the disk)
  • initialized a physical volume

    $ pvcreate /dev/sdb3
    Physical volume "/dev/sdb3" successfully created
    
  • extended the volume group to include this new physical disk

    $ vgextend myvg /dev/sdb3
    Volume group "myvg" successfully extended
    
  • extended the logical volume (I think this is where I ballsed it up: I think I should have pvmove'ed stuff to the new pv in that group - can someone confirm?)

    $ lvextend /dev/mapper/myvg-root /dev/sdb3
    

I would now like to undo the lvextend and then proceed with the original plan of moving the content of the old physical volume over to the new physical volume. Can I reduce the logical volume (I have not yet touched the ext4 partition that sits in /dev/mapper/myvg-root with something like resizefs) without fear of damaging the ext4 filesystem? If so, how do I tell it to reduce by exactly the right amount?

$ lvreduce --by-exactly-the-amount-occupied-by-PV /ev/sdb3 /dev/mapper/myvg-root

© Server Fault or respective owner

Related posts about lvm

Related posts about ext4