Fixing a corrupt Mirror

Verifying the LV is mirrored

Do lslv LVnameand look at the LVs and PPs, and the ‘copies’ value. If the LV is not mirrored, the copies = 1. If the value is higher than one, the following formula applies:

Copies x LVs = # Pps.

Example: 2 copies with 5 LVs should have a PP value of 10. If it is not ten, you may have a problem. Take note of the VGname field as it will be required for the next step.

Verify the VG is functioning as desired: Do lsvg -l VGname and verify the # of LPs and PPs match the information from running the lslv LVname above. If an error is returned similar “0516-1147 : Warning – logical volume Lvname may be partially mirrored”, then the LV and/or VG is corrupted and requires repair.

Run lslv -m LVname and see if all the required information is available. Ensure no fields are blank or empty; if they are, there is corruption requiring repair.

Example: Using hd9var:/var

LP    PP1  PV1               PP2  PV2               PP3  PV3

0001  0239 hdisk20           0245 hdisk21           
0002  0240 hdisk20           0221 hdisk2            0220 hdisk21           
0003  0241 hdisk20           0222 hdisk2            0220 hdisk0            
0004  0242 hdisk20           0223 hdisk2            0221 hdisk21           
0005  0243 hdisk20           0224 hdisk2            0221 hdisk0            
0006  0244 hdisk20           0225 hdisk2            0222 hdisk21           
0007  0245 hdisk20           0226 hdisk2            0222 hdisk0            
0008  0246 hdisk20           0227 hdisk2            0223 hdisk21           
0009  0247 hdisk20           0228 hdisk2            0223 hdisk0

In this example, mirror #3 is missing one of the LPs/PPs. The mirror must be broken to remove the bad copy using the command rmlvcopy LVname #mirrors_desired Ppname, for example rmlvcopy hd9var 2 hdisk0

If this fails, you will be required to remove them manually. As there is a risk of system corruption, it is vital to ensure a known good and current mksysb backup is available before proceding.

Run lslv LVname and make note of the LVid. Next, run the following command to output that to a text file:

lquerylv -L LVid -r > /tmp/lvname.mapfile

Edit the file and remove all of the good entries, leaving only the ones from the mirror you want removed. From the example above, you would want to keep all of the entries from Mirror #3.

Next, we need the number of PPs to remove by counting the lines of the mapfile, using wc -l /tmp/LVname.mapfile. This will be passed to the -s argument in the next command. In the case of the example given in this document, wc -l returned 8. Deallocate these PPs by running lreducelv against this map file as follows:

# lreducelv -l LVid -s 8 LVname.mapfile (where 8=Word count of lines from the mapfile)

Now validate the changes made: Verify using lslv -m LVname that there are the requisite number of copies of the Lps (2, in the example given). Verify lsvg -l VGname does not produce any more errors

If all was successful, the mirror can be re-implemented if required. On the example system given here, it would be added with the command:

mklvcopy hd9var 3 hdisk0 hdisk21

This would create a “3rd mirror” for LVname hd9var, using PVs hdisk0 and hdisk21.