Operating System - HP-UX
1825766 Members
2093 Online
109687 Solutions
New Discussion

Removing a VG with missing LV

 
Isquipa
New Member

Removing a VG with missing LV

Greetings.

While testing our storage product on HP-UX, sometimes volumes/vluns are removed without first running lvremove/vgreduce/vgremove. A subsequent test tries to clean up, create and export volumes/vluns and then run pvcreate/vgcreate/vgextend/lvcreate again using the same or similar vg_names. The problem is vgremove fails because the VG is still associated with an LV. The LV no longer exists so cannot be removed first.

vgexport fails saying the VG is still active. vgscan shows no active LVs but reports 1 LV for the VG. pvdisplay shows this:

--- Physical volumes ---
PV Name /dev/dsk/c8t0d1
PV Name /dev/dsk/c10t0d1 Alternate Link
PV Name /dev/dsk/c4t0d1 Alternate Link
PV Name /dev/dsk/c6t0d1 Alternate Link
VG Name /dev/dlh01
PV Status unavailable
Allocatable yes
VGDA 2
Cur LV 0
PE Size (Mbytes) 16
Total PE 639
Free PE 0
Allocated PE 639
Stale PE 0
IO Timeout (Seconds) default
Autoswitch On


--- Physical extents ---
PE Status LV LE
00000 current ??? 00000
00001 current ??? 00001
00002 current ??? 00002
00003 current ??? 00003
00004 current ??? 00004
.
.
.

Is there a way to clean this up without having to reboot?

Thanks!
7 REPLIES 7
Sandman!
Honored Contributor

Re: Removing a VG with missing LV

Try rebuilding the /etc/lvmtab file by doing a vgscan on the system. First back up the old lvmtab file and then create a new one with vgscan i.e.

# cp /etc/lvmtab /etc/lvmtab.old
# vgscan -av

Once the situtaion is corrected you can remove the LV and VG.
Patrick Wallek
Honored Contributor

Re: Removing a VG with missing LV

Have you tried deactivating the VG first?

# vgchange -a n /dev/dlh01

Then you should be able to vgexport it.
Isquipa
New Member

Re: Removing a VG with missing LV

Wow, you guys are fast!

I had tried vgscan -av but that didn't help.

vgchange looks like a step in the right direction, though now after over 10 minutes vgexport seems to be hung.
Sandman!
Honored Contributor

Re: Removing a VG with missing LV

Do you know the lvol's name? If so you can try removing it by specifying the lvol as an argument to the lvremove(1M) command.
Sundar_7
Honored Contributor

Re: Removing a VG with missing LV

You could try MOVING the lvmtab, not just copy it.

# mv /etc/lvmtab /etc/lvmtab.OLD
# vgscan -av

If that doesn't help, you could try vgreduce with -f option to remove the missing PVs. It will not work if that is the only in PV in the VG. It might probably fail if there are any LVs in the missing PV.

Learn What to do ,How to do and more importantly When to do ?
Isquipa
New Member

Re: Removing a VG with missing LV

At one point I tried removing the LV by name, but lvremove reported that the LV didn't exist (don't remember the error string).

I have tried removing /etc/lvmtab and rebuilding using vgscan -av, but only the old PV and VG devices come back, not the LVs. I tried running pvremove and rmsf against the /dev/dsk and /dev/rdsk nodes, but vgcreate still fails, and vgscan recreates them. It seems to remember everything (from kernel space?) except the LVs.
Isquipa
New Member

Re: Removing a VG with missing LV

Turns out that vgexport isn't necessary anyway. Running vgchange to deactivate the missing VGs is sufficient to allow new VGs to be created.

Sorry Patrick, I owe you three more points -- guess I assigned them too soon. Thanks everyone for being so helpful!