Showing results for 
Search instead for 
Did you mean: 

LVM Mirror like in HPUX

Regular Advisor

LVM Mirror like in HPUX


I wanted to make a mirror copy for LV with different Physical volume in redhat linux 4.7 but it seems bit cofusion.

I have one VG=vg01
Two PV = sdb1,sdc1 each 1 gb.
I have one LV=mylv with the size of 512mb.

Now i needs to mirror mylv with physical volume sdc1 as below

#lvconvert -m1 /dev/vg01/mylv /dev/sdc1 but it givs error
Not enough PVs with free space available for parallel allocation.
Consider --alloc anywhere if desperate.

seems its looking for same phyiscal volume for mirror.


Ralph Grothe
Honored Contributor

Re: LVM Mirror like in HPUX

>> Consider --alloc anywhere if desperate.
>seems its looking for same phyiscal volume for mirror.

Yes, your assumption seems right.
You ought to be pretty desperate before you resorted to the "--alloc anywhere" option ;-)

You can look up how many free PEs there are in each PV.
Either issue

# vgdisplay -v vgrh|egrep 'PV Name|Total PE|PE Size'

or use this command

# pvs -o name,pe_count,pe_alloc_count,free /dev/sd[bc]1

You can also have a look at how those allocated PEs are mapped on the PVs by

# pvdisplay -m /dev/sd[bc]1

Besides, before there was introduced the mirroring option in Linux LVM2 the usual way to mirror accross different HDDs an their partitions was to build an MD RAID1 device beneath LVM and use that as a PV to create your mirrored VG.

One would do this by first marking same sized partitions on different HDDs of type 0xfd (i.e. autoraid) (e.g. by using fdisk /dev/sdb and fdisk /dev/sdc) and then run something like such:

# mdadm -C /dev/md0 -a md -l 1 -n 2 /dev/sd[bc]1

# mdadm -Dsv | grep -A1 md0 >>/etc/mdadm.cfg

# pvcreate /dev/md0

# vgcreate -s 16m vgbla /dev/md0

# lvcreate -L 2g -n lv_bla vgbla

# mke2fs -j /dev/vgbla/lv_bla

Madness, thy name is system administration
Honored Contributor

Re: LVM Mirror like in HPUX

The LVM-level mirroring functionality seems to be a bit rough in RHEL 4.x, and apparently still is in RHEL 5.

The error may be because lvconvert wants to allocate a small amount of disk space for the mirror log, which ideally should be not on the same disks as the mirror halves (i.e. you would need a small *third* PV in your VG for the mirror log).

If you're mirroring for short term only (e.g. you're performing a SAN migration, and will remove the "old" side of the mirror as soon as the mirroring to the "new" side is complete), you might use the "--corelog" option:

lvconvert -m1 --corelog dev/vg01/mylv /dev/sdc1

If you use the --corelog option and the system is rebooted while the mirror exists, the mirror must be fully resynchronized from the original. So it is *not suitable* for long-term use.

Steven E. Protter
Exalted Contributor

Re: LVM Mirror like in HPUX


For proper mirror, I would use lvmove to get the data on to one physical volume and then run the mirror configuration posted above, not what you originally tried.

I am guessing your mylv logical volume is spread across two disks. To have mirror have any use, you need to get all the data to one disk and THEN mirror.


Steven E Protter
Owner of ISN Corporation
Viktor Balogh
Honored Contributor

Re: LVM Mirror like in HPUX


Yeah, as Matti said, you need three PVs for a two-way mirroring on Linux. This was strange also to me, but got used to it.
Altough the --corelog option isn't recommended.
Unix operates with beer.