How to replace a corrupted SD-UX INDEX file

Jump to: navigation, search


Once in a while, the SD-UX sofware database /var/adm/sw/products/INDEX file may become corrupt or overwritten. Following are presented two procedures to try to recover the INDEX file before searching your backup media.

The recommended method is using "swmodify" command. This provided the cleanest recovery of the database. Using an empty or void fileset is similar in approach to swmodify, but only works correctly in HP-UX 10.20 or 11.0. The WTEC script it's a last effort and you should already evaluate recoverying the INDEX file from your backup before trying it.

Using swmodify[edit]

# swlist -l fileset | grep -i Q4
# swmodify -a state=configured OS-Core.Q4

That rebuild the INDEX file.

Installing an "empty" fileset[edit]

Only use this method on HP-UX 10.20 and 11.0. An empty software depot may be created to rebuild the software database. The "void" depot is installed and removed from the system to regen a clean database.

1. Check the existence or status of the current INDEX file.

# ll /var/adm/sw/products/INDEX
/var/adm/sw/products/INDEX not found


# ll /var/adm/sw/products/INDEX
-rw-r--r--   1 root       sys              0 Nov 16 15:55 /var/adm/sw/products/INDEX

2. Create a empty package file descriptor

# printf "product\ntag void\nfileset\ntag void\n" > /tmp/void.psf

3. Verified the file descriptor.

# cat /tmp/void.psf
tag void
tag void

4. Create a software package for the "void" product.

# swpackage -s /tmp/void.psf

=======  11/22/07 10:46:22 MST  BEGIN swpackage SESSION

       * Session started for user "root@hostname".

       * Source:        hostname:/tmp/void.psf
       * Target:        hostname:/var/spool/sw
       * Software selections:

       * Beginning Selection Phase.
       * Reading the Product Specification File (PSF) "/tmp/void.psf".
       * Reading the product "void" at line 1.
       * Reading the fileset "void" at line 4.
WARNING: Incomplete definition for the fileset "void", beginning at
         line 3.  The following attributes are not defined:
                files            the files contained in the fileset

NOTE:    Creating new target depot "/var/spool/sw".
       * Selection Phase succeeded.

       * Beginning Analysis Phase.
       * Analysis Phase succeeded.

       * Beginning Package Phase.
       * Packaging the product "void".
       * Packaging the fileset "void.void".
       * Package Phase succeeded.

NOTE:    You must register the new depot "/var/spool/sw" to make it
         generally available as a source for swinstall and swcopy
         tasks.  To register it, execute the command

                swreg -l depot /var/spool/sw

=======  11/22/07 10:46:22 MST  END swpackage SESSION

5. Install "void" to generate a new product INDEX file.

# swinstall void

=======  11/22/07 10:48:28 MST  BEGIN swinstall SESSION
         (non-interactive) (jobid=hostname-0035)

       * Session started for user "root@hostname".

       * Beginning Selection
       * "hostname:/":  This target does not exist and will be created.
       * Source connection succeeded for "hostname:/var/spool/sw".
       * Source:                 /var/spool/sw
       * Targets:                hostname:/
       * Software selections:
       * Selection succeeded.

       * Beginning Analysis and Execution
       * Session selections have been saved in the file
       * The analysis phase succeeded for "hostname:/".
       * The execution phase succeeded for "hostname:/".
       * Analysis and Execution succeeded.

NOTE:    More information may be found in the agent logfile using the
         command "swjob -a log hostname-0035 @ hostname:/".

=======  11/22/07 10:48:33 MST  END swinstall SESSION (non-interactive)

6. Verified the new product INDEX file.

# ll /var/adm/sw/products/INDEX
-rw-r--r--   1 root       sys        1830171 Nov 22 10:49 /var/adm/sw/products/INDEX

7. Removed the "void" product.

# swremove void

Using WTEC "index_rebuild.scr"[edit]

This procedure should only be used as a last ditch effort before reinstall. This procedure is unsupported and the script was developed by WTEC, not for customer use.

  1. chmod 755 the script.
  2. Move the current /var/adm/sw/products/INDEX file to another location.
  3. The finished INDEX file is left in the /var/tmp directory.
  4. The script can be run from any location.
  5. The following 'set -x' statement should be commented out if you do not want extreme verbose output from this script.
  6. The stdout may be useful for troubleshooting if there are corrupted pfiles or filesets.
  7. To redirect the output from the screen to a file use the syntax when executing this script:
# index_rebuild.scr 2>/tmp/index.log 1>&2

-> index_rebuild.scr


set -x
cd /var/adm/sw/products
ls > /var/tmp/flist$$
[[ -e ifiles/INDEX ]] && cat ifiles/INDEX > /var/tmp/INDEX
# All bundles first
for dir in `cat /var/tmp/flist$$`
    [[ ! -d $dir ]] && continue
    [[ $dir = "ifiles" ]] && continue
    (cd $dir
        # If the only directory is "pfiles" then it is a bundle.
        if [[ `ls | wc -l` -eq 1 && -d "pfiles" && -f "pfiles/INDEX" ]]
            cat pfiles/INDEX >> /var/tmp/INDEX
# Ordinary products next
for dir in `cat /var/tmp/flist$$`

    [[ ! -d $dir ]] && continue
    [[ $dir = "ifiles" ]] && continue
    (cd $dir
        [[ `ls | wc -l` -eq 1 ]] && continue
        # If there are more than one subdirectory, then it is a product
        for pdir in pfiles [0-9A-Z]*
            if [[ -f "pfiles/INDEX" ]]
                cat ${pdir}/INDEX >> /var/tmp/INDEX