How do I clone an lvm ext3 partition to a smaller drive?
Solution 1:
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.
Solution 2:
An easy way to do this is to plug the new drive into your computer, configure LVM and otherwise partition this drive the way you want, make the file systems, and then use rsync
or just cp -a
to copy the files over. While not a high tech way of going about it, this will suffice for most people's needs.