Partitioning LVM – Move LVM 250 GB Root Partition to a New 120GB Hard Disk


I have the following situation:

My current Ubuntu (12.04) installation is running from an external HDD (250 GB) because I was to lazy to buy an new internal hdd. Now i've got a new internal (120GB) and i want to move everything to the internal. Installing Ubuntu new is out of disscussion because its to peronalized.

Luckily (i hope so) the root partition is partitioned with LVM, so i hope i can move the partition to the smaller internal HDD.

Is this possible? And where do i find help?

EDIT: This question already is quite old and could be outdated. I added the Ubuntu version that was used back then.

Best Answer

As you suspect, this is extremely elegant to do using LVM.

Shrink the existing installation to fit the smaller disk.

Physically install the new harddisk, format and pvcreate it, use vgextend to add it to the same vg as your root partition

Use pvmove to transparently move all data away from the old partition

Use vgreduce to remove your external hd from your vg. Unplug the old disk /dev/sdOLD.

In the example below:

  • /dev/sdOLD stands for the old partition to replace
  • /dev/sdNEW stands for the new partition to take its place.
  • vgX stands for the volume group

Example: Of course, you have to be 100% sure that your are using the right devices. Also, having complete and up-to-date backups, removed from the system, is essential.

pvcreate /dev/sdNEW
vgextend vgX /dev/sdNEW
pvmove /dev/sdOLD
vgreduce vgX /dev/sdOLD

Use update-grub and grub-install to make your new root disk bootable