My old computer recently died. It was old enough that I didn’t spend a lot of time trying to fix it. I took the opportunity to get a new one. I have my drives set up so that my “home” partitions are in an LVM volume group. I wanted to move that VG to the new drive on the new machine. This is what worked well for me.
Assuming you have the old drive connected to the new machine the simplest way seemed to be adding the physical volume on the new disk to the VG on the old disk then moving all of the extents that exist in the VG on the old disk to the new. Finally I removed the old disk from the VG.
Here are the steps I took, I will explain each after the code.
vgchange -ay pvcreate /dev/sda5 vgextend MyVG /dev/sda5 vgmove -v /dev/sdb3 /dev/sda5 vgreduce MyVG /dev/sdb3
1: That started up the MyVG volume group on the old HDD. Although it’s not shown above I mounted it and looked around to make sure the files were there and everything looked good.
2: I allocated the partition on the physical disk in the new machine (sda5 for me) to LVM.
3: Here I added the LVM physical volume (pv) created above to the MyVG volume group that up to this point resided only on the old HDD. So now instead of a 100G “disk” only on the 1 HDD I now had a 360G “disk” that actually spanned 2 physical disks.
4: This moved all of the physical extents of MyVG that resided on the old HDD (sdb3 for me) to physical extents on the new HDD. -v just gave me a 15 second rolling counter of the progress. It took about 25 minutes to move 100G or so.
5: This removed the old HDD from the MyVG. Everything is now on the same volume group it has always been on but that VG now resides fully on the new HDD now.
In case you are wondering why I didn’t just keep the old HDD I moved from a desktop machine to a laptop.
