[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: LVM: shrinking a logical volume (moving LVM logical volumes to new disks)


On Wed, Nov 19, 2014 at 12:24:27AM +0100, lee wrote:
> Hi,
> so far, I managed to pvmove a LV to my USB stick and from there to a
> backup disk in another machine.  Doing so, I found that I can split off
> LVs from a volume group and that this inevitably creates a new VG.  That
> leaves you stuck because it's impossible to move a LV from one VG to
> another, and it's also impossible to merge multiple VGs into one VG :(
> How stupid is that??

Well - you can merge VGs. and You and split VGs. so you could:

- pvcreate /dev/${usbdevice}
- use pvmove to move your LV of choice onto the USB stick.
- use vgsplit to split /dev/${usbdevice} into its on VG
- Sneakernet the USB stick to a new box
- Use vgmerge to join the USB stick to the box's VG
- Use pvmove to move the LV onto a local disk
- Use vgsplit to make the USB its own VG again
- Sneakernet the USB stick back to the original box
- Rinse and repeat.

But that's a fair number of steps...  You could also just:

- Create a file system on the USB device. and mount it.
- dd if=/dev/oldvg/vgname | gzip --best > /media/usbstick/somefile.gz
- Unmount and sneakernet to the new box

etc.. I'm sure you get the idea. No need to make it more complicated
than absolutely necessary.

> This means that I must move the remaining LVs from the server to the USB
> stick all at once because otherwise I'd end up with a number of VGs,
> each representing one LV, rather than a number of LVs within one VG.

Not quite...

[snipped lots of stuff that my tired braincells cannot cope with]

> (Note to self: Do not partition LVs but create LVs for swap partitions
> instead.)

Sounds like a sensible note. Unfortunately, if you use virtualisation,
you will often end up slicing off LVs to be presented to the virtual
machines as disks. And the VMs then partition them and/or create PVs
on them. Nested stuff galore.

Karl E. Jorgensen

Reply to: