2

For context, see my answer: Move a logical volume from one volume group to another.

I tried to use this recipe for real. See the transcript at https://gist.github.com/anonymous/1611380eafd0c738ef0f8ad09e0f0ab0

It looks like I didn't test this enough. While trying to apply this to my system, I got the following error

root@orwell:/tmp# lvconvert --type raid1 --mirrors 1 /dev/newdebian/debian_boot /dev/md2
  Logical volume newdebian/debian_boot successfully converted.

root@orwell:/tmp# lvconvert --splitmirrors 1 --name debian_boot_copy /dev/newdebian/debian_boot

  Unable to determine sync status of newdebian/debian_boot.
  Unable to split newdebian/debian_boot while it is not in-sync.

I'm not finding any information about this on the net, but I also think it's unlikely that I'm the first person in the world to run into this. Note that the two volume groups in this case are on separate md RAID devices. Here is what the layout currently looks like.

And I merged the debian VG into the newdebian VG.

This is an awkward position to be in - I may not be able to use my regular installation, which is on the debian VG, till this is fixed.

root@orwell:/tmp# lvs -a -o name,copy_percent,devices newdebian
  LV                     Cpy%Sync Devices                                        
  acl                             /dev/md1(80472)                                
  boot                            /dev/md2(35761)                                
  data                            /dev/md1(95835)                                
  debian_boot                     debian_boot_rimage_0(0),debian_boot_rimage_1(0)
  [debian_boot_rimage_0]          /dev/md1(0)                                    
  [debian_boot_rimage_1]          /dev/md2(36000)                                
  [debian_boot_rmeta_0]           /dev/md1(117666)                               
  [debian_boot_rmeta_1]           /dev/md2(35999)                                
  debian_home                     /dev/md1(12158)                                
  debian_root                     /dev/md1(238)                                  
  home                            /dev/md2(11920)                                
  postgres                        /dev/md1(105563)                               
  root                            /dev/md2(0)                                    
  swap                            /dev/md1(35999)                                
  swap                            /dev/md1(113243)                               
  vboxshare                       /dev/md1(117410)                               
  video                           /dev/md1(42072)                                
  video                           /dev/md1(83035)                                
  windows                         /dev/md1(36952)                                
  windows                         /dev/md1(80475)                                
  windows                         /dev/md1(114338)                               
  windows10                       /dev/md1(100955)                               
  windows10                       /dev/md1(115618)  

For the moment, I've converted back to linear

 root@orwell:/tmp# lvconvert --type linear /dev/newdebian/debian_boot
  Unable to determine sync status of newdebian/debian_boot.
  Logical volume newdebian/debian_boot successfully converted.

but of course, I'd like to know what the problem is.

Faheem Mitha
  • 35,108
  • Is the logical volume active? – Martian Jul 04 '17 at 12:16
  • @Martian Which logical volume? – Faheem Mitha Jul 04 '17 at 13:45
  • 1
    Which LV? Obviously the one you are manipulating: lvchange -ay newdebian/debian_boot. LVM does not synchronize inactive volumes. You should wait until Cpy%Sync is 100%. Then it should be safe to split. – Martian Jul 17 '17 at 16:41
  • @Martian It won't let you merge or split unless the relevant volumes are inactive. – Faheem Mitha Jul 17 '17 at 19:49
  • Nope, it will not let you split unless volume is in sync. And to query whether volume is in sync it must be active. (The truth is I tested only with latest LVM2 version.) And doing anything else is error prone and risking your data. – Martian Jul 18 '17 at 12:35
  • @Martian I see. I'll try experimenting with inactive logical volumes. Do you get error messages when logical volumes are inactive? – Faheem Mitha Jul 18 '17 at 13:13
  • I do, same as yours:
    Unable to determine sync status of newdebian/debian_boot. 
    Unable to split newdebian/debian_boot while it is not in-sync.
    
    – Martian Jul 18 '17 at 16:04
  • @Martian Oh, that's very interesting. That might well be the issue. But if so, why hasn't anyone else run into it? And don't the volumes need to be active to be synced in the first place? In any case, can you write an answer? – Faheem Mitha Jul 19 '17 at 01:01

1 Answers1

1

The following looks like LV is inactive:

root@orwell:/tmp# lvconvert --splitmirrors 1 --name debian_boot_copy /dev/newdebian/debian_boot

  Unable to determine sync status of newdebian/debian_boot.
  Unable to split newdebian/debian_boot while it is not in-sync.

I checked with 2.02.172 and it is exactly what I got when LV was inactive.

Splitting a leg is allowed only when RAID is in sync. And LVM is unable to determine whether the device is in sync while it is not active.

First you must activate the device before any attempts to split a leg:

lvchange -ay newdebian/debian_boot

And then wait for sync - there is no polling command in LVM to do that, you will have to either wait a while and check yourself, or write a script.

NOTE: It may be safer to use dmsetup status output, as for LVM version 2.02.171 and older 100% might be reported due to rounding while device was not fully in sync.

Only then you can successfully run the above lvconvert --splitmirrors operation.

Martian
  • 206
  • Thanks Martin. That's very helpful. I'll try to reproduce this myself. But what do you mean by "split a leg"? That isn't standard terminology. Presumably you mean run lvconvert --splitmirrors. – Faheem Mitha Jul 19 '17 at 23:08
  • 1
    For mirrors and RAID1 the images are often referred to as legs - see for example --mirrors option in lvcreate(8) man page. – Martian Jul 20 '17 at 09:33