LVM and the Ease of Migrating to a New Drive

Online data relocation to other drives using LVM and pvmove

These days my disks are filling up fast. My current PC holds 7 drives, including 2 NVMe drives. Actually 8 drives as I installed a new HDD today. All of my disks and partitions – with the notable exception of the FAT16 EFI partition for UEFI boot – are using LVM, the Logical Volume Manager.

With the availability of larger drives at reasonable costs, I decided to move some logical volumes (LV) spanning several drives onto one single drive, thus consolidating disks. This one drive will then be mirrored in a RAID-1 configuration for redundancy.

Note: In a multi-drive LVM Logical Volume each drive represents a potential point of failure. Moving the data from multiple drives onto one drive reduces that risk.

Relocating Data Online

I didn’t have any free SATA ports on my motherboard, except the one for the DVD drive. I thus decided to first move all the data to a new 12 TB drive before dealing with RAID. This is not necessarily the best/quickest way.

The first thing we need to do is create a partition table for the new hard drive. After installing and connecting the drive, check to see how it is listed:


Look for a “drive” that has no partition and compare it with the size of the drive you installed. Make sure you identified the new, empty drive. In my case, the new drive was listed as “/dev/sda”.

We need to create a partition table with a new LVM type partition. In a root terminal, type:

gdisk /dev/sda

Note: Replace /dev/sda with the drive designation of your empty drive.

Inside gdisk, type “p” to print the partition table. It should be empty! Now you can create a new partition by typing “n”.

At the first prompt press [Enter] to accept the suggested partition number. At the second prompt press again [Enter] to accept the suggested start of the partition. At the 3rd prompt press once more [Enter] to use the entire drive.

Now it’s time to specify the partition type. Enter


for LVM.

Press “p” to check that everything is alright. Once verified, press “w” to save the new partition table to disk and exit.

I assume you already have a Volume Group and Logical Volume(s). While still in the root terminal, type


to get a listing of your volume groups (VG in short). Look for the name of the volume group you wish to expand (to include your new shiny hard drive). Then extend the volume group using

vgextend vgname /dev/sda1

where “vgname” is the name of your Volume Group you wish to enlarge, and “/dev/sda1” the partition we just created on the new HDD (hard drive).



to get a list of all drives and their associated Volume Groups. Does everything look good?

Now comes the big moment – moving the content of the current disk(s) to the new disk. This is done with the following command:

pvmove /dev/sdd1 /dev/sda1

where the first argument “/dev/sdd1” is the disk whose content is to be moved, and the second argument “dev/sda1” is the target, that is our new drive. If you have multiple drives you wish to consolidate on one drive, you need to repeat this command for each drive, changing the first argument.

Alternatively, if you want to relocate data of only one drive to one or more drives in the VG, use the following syntax:

pvmove /dev/sdd1

This moves all data on /dev/sdd1 to the other physical drives within the Volume Group that the drive belongs to. Of course the VG needs to have enough free space to accommodate the data.

Note: The pvmove command can take a long time, depending on the disk size. Expect it to run several hours for multiple terabytes. The good news is that you can continue using the volumes that are being moved.

Before removing the old drive(s), we need to remove them from the Volume Group by entering:

vgreduce -v vgname /dev/sdd1

where “vgname” is the name of the Volume Group and “/dev/sdd1” the drive we wish to remove.

For more information on LVM and the “pvmove” command, see “Online Data Relocation” as well as the man pages. I will follow up with how to set up a RAID-1 array.

For more information on data storage, read how I monitor my drives for signs of imminent failures under “Monitoring Hard Drives Using Smartmontools“.

If this article has been helpful, click the “Like” button below. Don’t forget to share this page with your friends.

Author: Heiko Sieger

The day has 24 hours. If that isn't enough, I also use the night.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.