lvm2 pvmove Issue

Latest response

I am running a test using lvm2, specifically using pvmove.

 

What I've done is added drive sdb1 to my volume group vg_rh6

 

# vgextend vg_rh6 /dev/sdb1
No physical volume label read from /dev/sdb1
Physical volume "/dev/sdb1" successfully created
Volume group "vg_rh6" successfully extended
 

I then created a logical volume lv_datas

# lvcreate -L 250m -n lv_datas vg_rh6
Rounding up size to full physical extent 252.00 MiB
Logical volume "lv_datas" created
 

I format my logical volume lv_datas

# mkfs.ext4 /dev/vg_rh6/lv_datas

 

And finally mount it

# mount /dev/vg_rh6/lv_datas /mnt/lvdata/
 

I copy data over

# cp -R /etc/sysconfig/ /mnt/lvdata/
 

I add a second drive to my volume group

# vgextend vg_rh6 /dev/sdc1 

No physical volume label read from /dev/sdc1
Physical volume "/dev/sdc1" successfully created
Volume group "vg_rh6" successfully extended

 

It shows up fine

# pvs
PV         VG     Fmt  Attr PSize  PFree
/dev/sda2  vg_rh6 lvm2 a-   15.51g    0
/dev/sdb1  vg_rh6 lvm2 a-    5.00g 4.75g
/dev/sdc1  vg_rh6 lvm2 a-    4.00g 4.00g

 

I create a new logical volume

# lvcreate -L 300m -n lv_bkp vg_rh6
Logical volume "lv_bkp" created
 

And this shows up fine also

# lvs
LV       VG     Attr   LSize   Origin Snap%  Move Log Copy%  Convert
lv_bkp   vg_rh6 -wi-a- 300.00m                                     
lv_datas vg_rh6 -wi-ao 252.00m                                     
lv_root  vg_rh6 -wi-ao  11.54g                                     
lv_swap  vg_rh6 -wi-ao   3.97g

 

I don't know that this is a big deal, but I also format this new logical volume

# mkfs.ext4 /dev/vg_rh6/lv_bkp
mke2fs 1.41.12 (17-May-2010)

 

Then I finally initiate pvmove

# pvmove /dev/sdb1 /dev/sdc1
  /dev/sdb1: Moved: 2.2%
  /dev/sdb1: Moved: 45.7%
  /dev/sdb1: Moved: 100.0%

 

Once it finishes I check the original physical volume and it says that it is empty.

# pvdisplay /dev/sdb1
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg_rh6
  PV Size               5.00 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              1279
  Free PE               1279

  Allocated PE          0
  PV UUID               KqVMC0-cH8N-P0II-I27C-HFXF-sZIZ-o0LQUl
  

The second physical volume shows to have data.

# pvdisplay /dev/sdc1
  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               vg_rh6
  PV Size               4.00 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              1023
  Free PE               885
  Allocated PE          138

  PV UUID               i11arc-VXrl-e72V-9N9c-H2fw-laTC-HFM0Pw

 

Ok, here is my issue. What step do I take next to access the newly moved data on /dev/sdc1?

 

I've tried mounting the logical volume that I created previously (lv_bkp) to my system and although pvdisplay shows that I got data on /dev/sdc1, I don't know what I need to do to access it?
 

Responses

I guess I just had to think about it and understand the
concept of LVM and its layers.

I was mentality stuck at the fact that when you mount a logical volume in LVM is *not*
like mounting an actual disk partition (such as /dev/sdb1). So running pvmove, I expected
to see the identical data yet on a separate logical volume.

I now understand that I can extend a volume group, move the data over or logical extents
using pvmove to the new physical volume or disk, and this will take care of everything
for me without having to unmount the logical volume (such as /mnt/data).

At this point, I can use vgreduce to remove one of the disks or physical volumes from the
volume group. And remove it completely from LVM using pvremove.

Ok, I believe its becoming more clear now thanks.