Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I currently have a LVM volume that is 128 GB. It has one physical drive associated to it.

If I were to add a second drive to expand it, but then later remove it, would I get data loss. I know that seems like an obvious question, but if I removed it, it would be because I would have less space taken up and would be use 128 GB or less.

I have also looked at the continuous properly on the servers webmin panel and am curious if that would allow this or how it would affect it.

share|improve this question
add comment

2 Answers

When you expand a volume group over more than one physical volume you have a JBOD array, so if any of the physical volumes are removed (manually or through damage/degradation) you have little hop of getting your data back (actually, you are likely to be able to get some back from the remaining working physical device, but it is far from guaranteed). Treat a multi-drive volume group as you would a RAID0 volume (unless the individual physical volumes are RAID arrays (R1 or higher) themselves you are in a similar position with regard to data safety, so make sure everything non-volatile is part of a tested backup plan).

With regard to cleanly removing a physical volume from a volume group, that is possible (and not difficult).

  1. Reduce the size of your filesystems (with resize2fs for ext2/3/4 volumes) and reduce the logical volumes they exist on (with lvresize), or just remove excess logical volumes, so that you have free space on the volume group at least as large as the device you wish to remove (use vgs or similar to check this).
  2. Once that is done use pvmove to move any data in extents on the device to be removed onto other devices in the volume group (for instance pvmove -v /dev/hdc1, note that this may take some time).
  3. When that is complete you can remove the physical volume from the group (with vgreduce), remove the LVM metadata from the physical volume to avoid potential confusion later (pvremove).

The main thing that you can do wrong in the above process is reducing the logical volumes too much (making it smaller than you resized the filesystem to using resize2fs) which will later lead to errors and corruption. A common way to make this mistake is to get confused between 1000-based units and 1024-based ones, so be careful with those. If you are only removing logical volumes rather than resizing any, or you have enough unallocated space in the volume group already without doing either, you don't need to worry about this.

share|improve this answer
add comment

You'd have to shrink your filesystem first, then shrink you logical volume to a size smaller than your first disk. Then you should be able to remove your second drive from the logical volume without data loss.

share|improve this answer
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.