Bug 799501

Summary: YaST fails to remove existing logical volume group
Product: [openSUSE] openSUSE Tumbleweed Reporter: Forgotten User xRcrmyYBVX <forgotten_xRcrmyYBVX>
Component: InstallationAssignee: Steffen Winterfeldt <snwint>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Critical    
Priority: P5 - None CC: aschnell, mpluskal
Version: 13.1 Beta 1   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard: GOLD
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: YaST error message when trying to remove VGroup
YaST2 logs

Description Forgotten User xRcrmyYBVX 2013-01-20 17:46:54 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17

During installation I want to remove an existing logical volume group and create a new one on an existing partition.

YaST fails to remove the existing volume group, showing the attached message.

On the command line, 
---------
# vgremove <vgname>
---------
fails with exit code 5. I must use
---------
# vgremove --force <vgname>
---------
to succeed.

Reproducible: Always

Steps to Reproduce:
1. Let YaST remove an existing VGroup

Actual Results:  
Fails with exit code 5
Comment 1 Forgotten User xRcrmyYBVX 2013-01-20 17:47:50 UTC
Created attachment 521000 [details]
YaST error message when trying to remove VGroup
Comment 2 Forgotten User xRcrmyYBVX 2013-01-20 17:51:03 UTC
Exit code 5 means:
"can't remove volume group containing logical volumes"

It looks like YaST does not remove logical volumes contained inside the vgroup first. Hence, either remove them prior to removing a volume group or use the "--force" parameter with the call of 'vgremove'.
Comment 3 Arvin Schnell 2013-01-21 08:14:27 UTC
Please provide YaST logs, see http://en.opensuse.org/openSUSE:Bugreport_YaST.
Comment 4 Forgotten User xRcrmyYBVX 2013-01-21 11:18:45 UTC
Created attachment 521102 [details]
YaST2 logs
Comment 5 Arvin Schnell 2013-01-23 17:06:40 UTC
The YaST logs show that YaST does remove the 6 logical volumes present
before removing the volume group. There is even a vgdisplay call right
before the vgremove call showing that no logical volumes are left.

Looks like a LVM problem.
Comment 6 Forgotten User xRcrmyYBVX 2013-01-23 21:07:11 UTC
Yes, you are right. I apologize for pointing the finger at YaST too quickly! I actually assumed YaST was not removing LVs simply due to the explanation of exit code 5, without looking at the logs.

I see that lvm2.02.98 is the latest version out there. Hence I sent an email to the linux-lvm list.

Should this report be reassigned?
Comment 7 Forgotten User xRcrmyYBVX 2013-01-24 10:32:15 UTC
Testing this in VirtualBox shows that openSUSE 12.3 Beta 1 using
  LVM version:     2.02.98(2) (2012-10-15)
  Library version: 1.02.77 (2012-10-15)
  Driver version:  4.23.0
fails to remove an empty volume group using 'vgremove VG' (exit code 5)

But openSUSE 12.2 (DVD)
  LVM version:     2.02.84(2) (2011-02-09)
  Library version: 1.02.63 (2011-02-09)
  Driver version:  4.22.0
succeeds to remove an empty volume group using 'vgremove VG' (exit code 0)

I sent a message to Linux-LVM mailing list:
https://www.redhat.com/archives/linux-lvm/2013-January/msg00015.html
Comment 8 Forgotten User xRcrmyYBVX 2013-01-24 11:18:39 UTC
After some IRC discussions, the problem seems to be that in openSUSE 12.3 installation, /etc/lvm to /mounts/mp_0000/etc/lvm/, which is mounted read-only.
In openSUSE 12.2 installation, /etc/lvm was writable!

See IRC log below:
----------------
[12:04] <kabi_> jbrauchle: hi - do you have writeble  /etc/lvm ?
[12:07] <jbrauchle> No, /etc/lvm symlinks to /mounts/mp_0000/etc/lvm/, which is mounted read-only
[12:07] <kabi_> yep - that's the problem
[12:08] <kabi_> there is missing error message
[12:08] <kabi_> disable -A n  
[12:08] <kabi_> with your vgremove
[12:08] <mcsontos> jbrauchle, you need to edit lvm.conf so backup_dir and archive_dir points to R/W location
[12:08] <mcsontos> jbrauchle, that should do the trick
[12:09] <mcsontos> More than that, I am surprised lvremoves succeeded
[12:09] <kabi_> mcsontos: he uses -A n for lvremove
[12:09] <mcsontos> OIC
[12:10] <jbrauchle> ok... so then, if I understand correctly: If openSUSE 12.2 installation works OK with exactly the same setup (root FS also read-only), there must be something wrong lvm.conf?
[12:11] <mcsontos> jbrauchle, or in installer
[12:11] <mcsontos> jbrauchle, e.g. FS mounted RO while it used to be R/W
[12:12] <kabi_> jbrauchle: there could be   backup{archive=0}  in lvm.conf
[12:12] <mcsontos> or so
[12:12] <jbrauchle> ok thanks! I will double check the difference from 12.2 to 12.3
[12:12] <kabi_> jbrauchle: any  backup{backup=0} as well
[12:12] <kabi_> (and)
[12:14] <jbrauchle> ok, you're right. On 12.2 /etc/lvm is writeable!
----------------
Comment 9 Forgotten User xRcrmyYBVX 2013-02-12 09:25:17 UTC
The problem still exists in 12.3 RC1.

If this cannot be fixed until 12.3 final, it may prevent users with existing LVM partitions from upgrading successfully.
Comment 10 Dong Mao Zhang 2013-02-20 09:38:45 UTC
bnc#781402 is very similar to this.
adding 'udevadm settle' before vgremove could prevent race conditions
Comment 11 Forgotten User xRcrmyYBVX 2013-02-20 14:54:05 UTC
Well, as I can't view bnc#781402 I can't judge if its similar...

From my limited knowledge of whats happening, I understand that LVM
a) needs a writable path to store archives and backups of metadata. Usually this defaults to /etc/lvm/{archive,backup}, but this is mounted read-only in the inst-sys of 12.3 (was read-write in 12.2)

OR

b) must be told to not create archives or backups of metadata in /etc/lvm.conf like so:
------------
backup {

    # Should we maintain a backup of the current metadata configuration ?
    # Use 1 for Yes; 0 for No.
    # Think very hard before turning this off!
    backup = 0

    # Should we maintain an archive of old metadata configurations.
    # Use 1 for Yes; 0 for No.
    # On by default.  Think very hard before turning this off.
    archive = 0
}
------------

So I guess option a) would be more sane...
Comment 12 Dong Mao Zhang 2013-02-21 06:28:17 UTC
(In reply to comment #11)
> Well, as I can't view bnc#781402 I can't judge if its similar...
> 
> From my limited knowledge of whats happening, I understand that LVM
> a) needs a writable path to store archives and backups of metadata. Usually
> this defaults to /etc/lvm/{archive,backup}, but this is mounted read-only in
> the inst-sys of 12.3 (was read-write in 12.2)
> 
> OR

If so, backup_dir and archive_dir could be changed to other directory in lvm.conf.

Because lvremove or vgchange will store metadata backup in /etc/lvm/backup and 
archive previous medadata to /etc/lvm/archives.

I believe changing default location of (backup, archive) could resolve this.
Can you test it again after changing /etc/lvm/lvm.conf?
Comment 13 Forgotten User xRcrmyYBVX 2013-02-21 16:49:30 UTC
As /etc/lvm/lvm.conf is also read only, I was unable to change it...
Comment 17 Arvin Schnell 2013-02-25 16:01:17 UTC
*** Bug 802120 has been marked as a duplicate of this bug. ***
Comment 18 Forgotten User xRcrmyYBVX 2013-02-28 14:27:23 UTC
In RC2 is looks like vgremove is called with the '-f' parameter, thus working around this problem. 

I'm not really convinced this is a real fix, as LVM cannot archive/backup any metadata in the current configuration...
Comment 19 Dong Mao Zhang 2013-03-22 08:03:47 UTC
(In reply to comment #18)
> In RC2 is looks like vgremove is called with the '-f' parameter, thus working
> around this problem. 
> 
> I'm not really convinced this is a real fix, as LVM cannot archive/backup any
> metadata in the current configuration...

how about my solution in comment#16?
change the backup and archive to /var/log?
Comment 20 Arvin Schnell 2013-03-22 09:03:27 UTC
(In reply to comment #18)
> In RC2 is looks like vgremove is called with the '-f' parameter, thus working
> around this problem. 
> 
> I'm not really convinced this is a real fix, as LVM cannot archive/backup any
> metadata in the current configuration...

The option -f was added for another issue, see bug #781402.
Comment 21 Arvin Schnell 2013-03-22 09:06:28 UTC
(In reply to comment #19)

> how about my solution in comment#16?
> change the backup and archive to /var/log?

/var could be on another device and thus be present only later during
booting. This could cause problems. Did you try that?

If the only problem is that /etc/lvm is read-only during installation
ask Steffen Winterfeldt to make it read-write.
Comment 22 Forgotten User xRcrmyYBVX 2013-03-22 09:17:47 UTC
I think all the other lvm commands (like lvremove) used by yast use "-A n -f"... hence, there is no archiving of metadata anyway, right?

If so, the newly added "-f" option for vgremove solves this problem.
If not, possibly make "/etc/lvm" writable again as it was in 12.2 and before...?
Comment 23 Arvin Schnell 2013-03-22 09:27:20 UTC
I don't know whether the -f option changes the archiving of the commands.
At least that is not mentioned in the man-pages.

We added the -f option to remove volume groups that had some inactive
logical volumes due to missing physical volumes.
Comment 24 Forgotten User xRcrmyYBVX 2013-03-22 10:06:14 UTC
No, the "-f" option for vgremove itself does not change archiving options, *but* as archiving is currently not possible due to read-only /etc/lvm/ directory, the "-f" option forces the operation to still proceed. Hence, it indirectly contributes to not archiving metadata in the current setup.
Comment 25 Arvin Schnell 2013-03-22 10:14:12 UTC
Ok, that sounds reasonable.

So /etc/lvm should still be made read-writable.
Comment 26 Stephan Kulow 2013-10-24 13:12:49 UTC
the priority field is for the developer not for the reporter
Comment 27 Forgotten User xRcrmyYBVX 2015-01-12 07:44:27 UTC
Cleaning my bug reports... I think this is resolved (somehow).