Linux – How to clone an lvm ext3 partition to a smaller drive

ext3linuxlvm

I have an lvm ext3 partition that is larger than the drive I would like to clone it onto, but is nowhere close to full, so all of the data, itself, would fit.

What would be the best way to clone this drive to the smaller one?

I would prefer to not have to resize the partition first, if possible.

Best Answer

LVM has built-in support for removing disks from volume groups!. No need for weird uses of copy commands or shrinking.

It is unclear if you mean by "partition" a logical volume. Also, when you say that you wish to use the smaller disk do you mean to get rid of the larger one?

Assuming that you want to stop using the larger disk/partition and remove it from the volume group you would have to:

  • add (pvcreate) the smaller disk/partition to the volume group
  • move (pvmove) the physical extents away from larger disk/partition. See this
  • remove (pvremove) the larger disk/partition from the volume group and do what you will with it.

Oh, and get a good backup first.