0
  • First:
    pvcreate /dev/sdb(1GB)
    vgcreate vg1 /dev/sdb
    lvcreate -n lv1 -l 100%FREE vg1
    
    then mount to /data
  • Second:
    1. upload 500MB file to /data
    2. add 3GB disk, create pv (/dev/sdc) and add it to vg1
    3. upload 1GB file to /data

Now:

  • 2 physical volumes (/dev/sdb, /dev/sdc)
  • 1 volume group (/dev/vg1)
  • 1 logical volume (/dev/vg1/lv1)
  • mount at /data contains 1.5GB file

Question: how to migrate /dev/sdb data to /dev/sdc to remove physical volume /dev/sdb?

Desired result:

  • 1 physical volume (/dev/sdc, 3GB)
  • 1 volume group (/dev/vg1)
  • 1 logical volume (/dev/vg1/lv1)
  • mount at /data contains 1.5GB file
2

You can "empty" a physical volume with pvmove so in your case pvmove /dev/sdb will move all allocated extents from sdb to sdc. After that you can remove sdb from the volume group with vgreduce vg1 /dev/sdb.

3
  • Thanks a lot , I will try
    – luckyheng
    Jul 30 at 9:27
  • I got 'No extents available for allocation'.then I add third disk 10GB create pv add to vg1 then run pvmove /dev/sdb /dev/sdd system restart and hangs I poweroff it when start I edit start options add init=/bin/bash then I type /usr/sbin/lvm and run pvmove /dev/sdb /dev/sdd got success but next run /pvmove /dev/sdc /dev/sdd failed
    – luckyheng
    Jul 30 at 10:04
  • Please add pvs output to the question. If sdb has 1 GB and sdc 3 GB you should have enough free space for the pvmove. Jul 30 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.