lvremove fails to remove lvol

Scenario:
A mismatch exists between the Cur LV and Open LV:

— Volume groups —
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 8
Open LV 9
Max PV 16
Cur PV 2
Act PV 2
Max PE per PV 4384
VGDA 4
PE Size (Mbytes) 32
Total PE 8748
Alloc PE 1432
Free PE 7316
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0

Looking at vgdisplay -v vg00, lvol9 is zero length.

LV Name /dev/vg00/lvol9
LV Status available/syncd
LV Size (Mbytes) 0
Current LE 0
Allocated PE 0
Used PV 0

This is a valid size for LVM and normally this lvol can be removed, but:

# lvremove /dev/vg00/lvol9
lvremove: Couldn’t delete logical volume “/dev/vg00/lvol9”:
The supplied lv number refers to a non-existent logical volume.

But the device files look OK:

# ll
total 32
drwxr-xr-x 2 root root 8192 Apr 10 11:42 .
dr-xr-xr-x 16 bin bin 8192 Feb 24 20:31 ..
crw-r—– 1 root sys 64 0x000000 Jun 30 2011 group
brw-r—– 1 root sys 64 0x000001 Feb 24 20:30 lvol1
brw-r—– 1 root sys 64 0x000002 Jun 30 2011 lvol2
brw-r—– 1 root sys 64 0x000003 Jun 30 2011 lvol3
brw-r—– 1 root root 64 0x000004 Jul 5 2011 lvol4
brw-r—– 1 root sys 64 0x000005 Jun 30 2011 lvol5
brw-r—– 1 root sys 64 0x000006 Jun 30 2011 lvol6
brw-r—– 1 root sys 64 0x000007 Jun 30 2011 lvol7
brw-r—– 1 root sys 64 0x000008 Jun 30 2011 lvol8
brw-r–r– 1 root sys 64 0x000009 Apr 10 11:42 lvol9
crw-r—– 1 root sys 64 0x000001 Jun 30 2011 rlvol1
crw-r—– 1 root sys 64 0x000002 Jun 30 2011 rlvol2
crw-r—– 1 root sys 64 0x000003 Jun 30 2011 rlvol3
crw-r—– 1 root root 64 0x000004 Jul 5 2011 rlvol4
crw-r—– 1 root sys 64 0x000005 Jun 30 2011 rlvol5
crw-r—– 1 root sys 64 0x000006 Jun 30 2011 rlvol6
crw-r—– 1 root sys 64 0x000007 Jun 30 2011 rlvol7
crw-r—– 1 root sys 64 0x000008 Jun 30 2011 rlvol8
crw-r–r– 1 root sys 64 0x000009 Apr 10 11:41 rlvol9

So the LVM tables for lvol mapping are corrupted. There are a few circumstances where this can happen but it is easy to fix. Use rmsf (*NOT* rm) to remove the device files. This will update the LVM tables in memory.

# rmsf /dev/vg00/lvol9
# rmsf /dev/vg00/rlvol9

Now the VG displays normally (Cur LV is the same as Open LV).

# vgdisplay -v vg00
— Volume groups —
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 8
Open LV 8
Max PV 16
Cur PV 2
Act PV 2
Max PE per PV 4384
VGDA 4
PE Size (Mbytes) 32
Total PE 8748
Alloc PE 1432
Free PE 7316
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0

– See more at: http://serviceitdirect.com/blog/lvremove-fails-remove-lvol#sthash.6RH7QBpv.dpuf


Tags: