Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 06-18-2009, 07:01 AM   #1
LQ Newbie
Registered: Nov 2006
Location: Finland
Distribution: OpenSuse
Posts: 26

Rep: Reputation: 15
Question LVM - unable to mirror LV

Hello guys,

I'm having problems to mirror a logical volume to two different PV.

membit:~ # pvscan
  PV /dev/sdb2   VG rootvg   lvm2 [465.67 GB / 12.70 GB free]
  PV /dev/sda1   VG datavg   lvm2 [149.05 GB / 149.05 GB free]
  PV /dev/sdc1   VG datavg   lvm2 [372.61 GB / 342.61 GB free]
  Total: 3 [987.32 GB] / in use: 3 [987.32 GB] / in no VG: 0 [0   ]

membit:~ # pvdisplay /dev/sda1 /dev/sdc1
  --- Physical volume ---
  PV Name               /dev/sda1
  VG Name               datavg
  PV Size               149.05 GB / not usable 1.31 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              38156
  Free PE               38156
  Allocated PE          0
  PV UUID               uDXi31-5AX9-LRDl-W9sN-nEGK-XYfX-QCYXLl

  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               datavg
  PV Size               372.61 GB / not usable 3.56 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              95387
  Free PE               87707
  Allocated PE          7680
  PV UUID               jU7spD-Kad7-7oUC-16nd-ipiT-dj5c-gBqOBx

membit:~ # lvdisplay datavg/mirroredlv
  --- Logical volume ---
  LV Name                /dev/datavg/mirroredlv
  VG Name                datavg
  LV UUID                Ttd1cF-6hQO-s619-fhCQ-ZUo2-qTeb-4EspEh
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                30.00 GB
  Current LE             7680
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:6
OK, now if I try to add a mirror to the LV:

membit:~ # lvconvert -m 1 datavg/mirroredlv
  Insufficient suitable allocatable extents for logical volume : 7680 more required
  Unable to allocate extents for mirror(s).
HW/OS specs:
Distro: OpenSUSE 11.1 x86
/dev/sda = P-ATA 160GB
/dev/sdc = S-ATA 2 400GB
What am I doing wrong??

Last edited by membit; 06-18-2009 at 07:04 AM.
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-20-2009, 03:42 AM   #2
LQ Newbie
Registered: Jun 2009
Location: Beaverton, OR
Distribution: Centos, Gentoo, OpenSuse
Posts: 1

Rep: Reputation: 2
I happened to be building an LVM mirror when I saw this post so I was able to test your setup and confirm the problem. The error is not quite accurate since it sounds like you don't have enough space to build the mirror (which you obviously do) when the real problem is that LVM can't build the mirror log.

You have two methods available for storing the log. The first (and easiest) is to store it in memory by adding '--mirrorlog core' to your lvconvert command. The second is to add a third PV to your datavg VG. LVM defaults to the PV method and you only have two PVs in that VG which is why your lvconvert failed.

The downside to using the memory based log is that your mirror will have to resync on every boot because LVM will not know the current state of the mirror.

The log size is very small since it only requires 1 bit per mirror region. The mirror region size defaults to 512K but can be changed with '--regionsize <size in MB>'.

If you use the PV log, be aware that prior to LVM2 2.02.44 the log size will be exactly 1 PE so you will want to increase the extent size on your PV when you create it and/or increase the region size on your mirror. Using the defaults for both will limit your mirror size to 16G (4K PE * 8 bits * 512K regionsize).
2 members found this post helpful.
Old 01-03-2015, 08:01 PM   #3
LQ Newbie
Registered: Jan 2015
Location: Brisbane, Australia
Distribution: Fedora
Posts: 1

Rep: Reputation: Disabled
Hi just a note to possibly save others some time with regard to conversion of lvm2 (linear) logical volumes to mirrored volumes using lvconvert, eg, to implement raid1 redundancy on an existing linear lv.

Since about September 2013, the default mirror segment type in lvm2 has been 'raid1' (not 'mirror'). This makes '--corelog' and '--mirrorlog disk/core/mirrored' options inapplicable in this default case, because raid1 segment type always stores its logs (in fact, metadata subvolumes) on-disk on the same PVs as the lv being mirrored. You no-longer need a third pv for the log, or to store the log in-memory.

There are two further implications. First, the command to create the mirror is simplified, because there is only a need to specify the lv to be mirrored, and the (usually one) pv on which the mirror segment will be stored:

lvconvert -m1 /dev/my_vg/my_lv /dev/my_new_pv
Second, there are a couple of space considerations. You need to have:
  • obviously, space on the mirror pv to store the copy of the original lv
  • but also, 1 additional LE on the mirror pv, to store the log
  • AND ALSO (and this is the point I missed for some time), 1 additional LE on the original lv, to store the log (since the log is stored on BOTH the original pv and the new pv)

In some cases this third space requirement causes a problem because there is no space in the existing lv for even 1 new LE to be allocated for the log. In this case, you might get an error such as:
1 extents needed, but only 0 available
(unhelpfully not indicating that the LE is required on the original pv, not the new pv)

The remedy is to resize the existing lv (and other lvs on the same pv, and the underlying filesystems, if necessary) so that there is enough space on the existing lv to allocate 1 additional PE for the log. In my case, for example, my existing pv was completely full, so I had to:
  • resize each filesystem on the pv to make each slightly smaller (use resize2fs)
  • then resize each lv to make each slightly smaller to allow room for logs (use lvreduce)
  • and only then, use lvconvert to create the mirrors


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which is the Best in LVM, Integrated Mirror or Integrated Stripping? RMLinux Linux - Newbie 3 12-04-2008 02:00 AM
LVM to mirror boot disk on Linux? danie1 Linux - General 1 12-03-2008 04:39 PM
RedHat - Howto mirror boot disk using LVM go3mon Linux - Enterprise 0 07-22-2008 05:51 AM
Unable to Setup LVM for HTPC jroggow Slackware 0 05-21-2007 10:06 PM
LXer: How To Create A Local Debian/Ubuntu Mirror With apt-mirror LXer Syndicated Linux News 0 01-04-2007 06:33 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration