DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.


Prevent and Detect Orphaned Mksysb NIM resources

In order to have a working mksysb resource in a NIM environment you need to have 2 items:   a NIM mksysb resource which points to a mksysb file in the filesystem. 
A good NIM mksysb resource looks like the image below.   The NIM mksysb resource is stored in the ODM and has a "location" attribute that points to a file in the filesystem.
image

However, if something (or someone) deletes the mksysb file from the filesystem, but doesn't delete the NIM mksysb resource, you are left with an orphaned mksysb NIM resource.   The mksysb resource will still show up in NIM and still appear to be useable, however any operations that try to use it will fail since its backing mksysb file isn't present.   An oprhaned mksysb resource looks like the image below:
image


How to prevent orphaned NIM mksysb resources:

The best way to prevent a orphaned NIM mksysb resource is to never delete mksysb files from the filesystem using "rm".   Instead, if you no longer need a NIM mksysb, use the "nim" command to delete it and also specify that the backing mksysb file should be deleted as well.   This can be done with a command such as this:
nim -o remove -a rm_image=yes aix3_mksysb
Substitute "aix3_mksysb" for the name of the mksysb that you want to delete.  The "-a rm_image=yes" tells NIM to not only delete the NIM resource from the ODM, but to also delete the backing mksysb file from the filesystem.

Detect orphaned NIM mksysb resources


Here is a handy one-line script that will check all your NIM mksysb resources and tell you if you have any orphaned mksysb resources that don't have a backing file present:

for mksysb in `lsnim -t mksysb | awk '{print $1}'`; do printf "%-20s " $mksysb; location=`lsnim -l $mksysb | grep location | awk '{print $3}'`; [ -e "$location" ] && echo " OK         $location" || echo " Not Found  $location"; done

The output looks like this:
aix1_mksysb           OK         /tmp/aix1_mksysb
aix2_mksysb           OK         /tmp/aix2_mksysb
aix3_mksysb           OK         /tmp/aix3_mksysb
aix4_mksysb           OK         /tmp/aix4_mksysb
aix5_mksysb           OK         /tmp/aix5_mksysb
aix6_mksysb           Not Found  /tmp/aix6_mksysb
aix7_mksysb           OK         /tmp/aix7_mksysb
aix8_mksysb           OK         /tmp/aix8_mksysb

Based on the output we can clearly see all of the mksysb's are good except for aix6_mksysb which doesn't have a a backing mksysb file present in the filesystem.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.