4

For testing purposes I've tried to extend my logical volume by attaching one more Physical Volume (USB drive). Making the USB drive part from the logical volume with the following steps:

  • Created partition from the device
  • Created Physical Volume from the new partition
  • Attached the Physical Volume to the already configured Volume Group
  • And finally extending the Logical Volume

My question is how to unmount and remove the USB drive without losing any data on the already existing Logical Volume?

4

for the resize2fs bit, it's like this:

e2fsck -f /dev/myvg/lvtest
resize2fs /dev/myvg/lvtest 96M #always a bit smaller than the LV

### then the rest as above
lvresize -l 100M /dev/myvg/lvtest
vgreduce myvg /dev/sdX

###then regrow that to fit the volume perfectly 
lvresize -l 100% /dev/myvg/lvtest
resize2fs /dev/myvg/lvtest 

I hope you're on ext2/3/4 . If on XFS, you may need to be creative!

2

In addition to not losing data.

The USB could be unmounted with data in its volume group/logical volumes.

The data and storage space in the USB will be available when mounted on a server.

I would say LVM formatted USB

enter image description here

2

Did you extend any filesystem in logical volume ?

if yes

reduce size of Filesystem (If this can be achieved) ... (remove file, use fsck -B).

if no

lvreduce --size 100M /dev/myvg/lvtest
vgreduce myvg /dev/rdsk/myusb

with obvious meaning for myvg and myusb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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