3

I have a logical volume, /dev/echohome/home01

It has three physical volumes: /dev/sda1, /dev/sdb1, /dev/sdc1

sda1 is 4TB w/ 0 extents available, sdb1 is 4TB w/ 476930 extents available, sdc1 is 1TB w/ 0 extents available

Current ext4 filesystem is ~45% full @ 3.1TB. Logical volume size is 6.37TB.

I would like to move ALL data to sda1 OR sdb1, then remove the other two PVs. Based on the reading I've done, I could try some combination of resize2fs pvmove and lvreduce to possibly accomplish what I'm looking for.

My specific detail that doesn't seem to be addressed in other questions is the physical location of the data that I'm trying to preserve -- if I don't know which PV a file physically resides on, how can I confidently resize2fs and then ultimately pvremove?

edit: I've considered that the simplest solution would probably be to backup the entire filesystem to a larger disk, shrink it, then move it back to a reconfigured LV, but I don't currently have the spare disk space. :(

1 Answer 1

5

My specific detail that doesn't seem to be addressed in other questions is the physical location of the data that I'm trying to preserve -- if I don't know which PV a file physically resides on, how can I confidently resize2fs and then ultimately pvremove?

You don't need to know that. That's LVM's job. resize2fs works on the logical volume, which is allowed to span multiple disks. Once your filesystem is small enough to fit onto one disk, you can tell LVM to move it over, and remove the other disks.


There are five steps to doing this.

  1. Reduce the size of the filesystem to less than 4TB. (resize2fs)

  2. Reduce the size of the logical volume to less than 4TB. (lvreduce)

    (This step can lose data if you truncate the logical volume to be smaller than the filesystem, so read the manpage!)

  3. Move the logical volume away from each drive. (pvmove <source pv> <dest pv>)

    (You'll need to do this one disk at a time.)

  4. Remove the disk. (vgreduce then pvremove)

  5. (Optional) If you made the logical volume larger than the filesystem in step 2, expand the filesystem to use the entire logical volume, so that no space is wasted. (resize2fs)

1
  • Thanks, this really helps me to understand more about the abstraction layers of LVM. This solution worked. Commented May 6, 2018 at 17:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.