#!/usr/bin/ksh # @(#) $Revision: 4.0 (HP-UX release 11) $ ############################################################################### # NOTE: This script is a contributed utility, no support for it will be # # provided by Hewlett-Packard. It can be used as-is. # ############################################################################### ############################################################################### # HEWLETT-PACKARD Country Response Center Belgium # #-----------------------------------------------------------------------------# # Shell Script Name : LVMcollect # # Author : Peter Van Giel updated by Alan Peacock # # Latest update : 20 Oct. 1995 - 08:00 # # Author latest update : pvg # #-----------------------------------------------------------------------------# # Name # # LVMcollect - Creates the Picture of Your LVM System Configuration. # # # # Synopsis # # # # Run LVMcollect: # # LVMcollect # # # # Run only a part of LVMcollect: # # LVMcollect -p[1|2|3|4|5|6|7|8|9] # # -p4 # # where: -p1 System Configuration # # -p2 Volume Groups # # -p3 Physical Volume Groups # # -p4 Logical Volumes # # -p5 Physical Volumes # # -p6 File Systems and Swap Space # # -p7 Root / Primary Swap / Dumps / Kernel Configuration # # -p8 LVM Device Files # # -p9 Other # # # # Run LVMcollect to get a detailed listing (verbose mode): # # LVMcollect -v # # # # Description # # LVMcollect is a tool that allows you to create the picture of your LVM # # system configuration. It is intended to be used on HP 9000 Series 700 # # and 800 systems that are configured to use Logical Volume Manager. # # LVMcollect makes an attempt to collect all the information you possibly # # need to know about the Logical Volume Manager system configuration. # # # # It can be used as a tool to troubleshoot LVM problems. By using # # LVMcollect you avoid going through all steps manually, which saves you # # a lot of time. It can also be used as a tool to document your LVM # # system configuration, so you have an accurate picture of your system in # # case of problems. # # # # Return Value # # 0 Successful completion. # # # # Errors # # + The names of physical volume groups are stripped down to maximum 12 # # characters by the vgdisplay(1M) command. Altough it is possible to # # work with longer names for physical volume groups, it is advisable to # # limit them to a maximum of 12 characters. # # # # + When using Physical volume links, a pvdisplay(1M) on the device file # # for the alternate link, refers to the primary link. The primary link # # device file that is indicated, seems to be always the primary link # # device file for the first disk in the chain. For example # # # # # pvdisplay /dev/dsk/c2t1d0 # # Device file path "/dev/dsk/c2t1d0" is an alternate path # # to the Physical Volume. Using Primary Link "/dev/dsk/c7t1d0". # # --- Physical volumes --- # # PV Name /dev/dsk/c7t1d0 # # PV Name /dev/dsk/c2t1d0 Alternate Link # # ... # # # # # pvdisplay /dev/dsk/c2t2d0 # # Device file path "/dev/dsk/c2t2d0" is an alternate path # # to the Physical Volume. Using Primary Link "/dev/dsk/c7t1d0". # # --- Physical volumes --- # # PV Name /dev/dsk/c7t1d0 # # PV Name /dev/dsk/c2t1d0 Alternate Link # # ... # # # # When doing a pvdisplay(1M) using the primary link device file, the # # alternate link is correctly identified, for example: # # # # # pvdisplay /dev/dsk/c7t1d0 # # --- Physical volumes --- # # PV Name /dev/dsk/c7t1d0 # # PV Name /dev/dsk/c2t1d0 Alternate Link # # ... # # # # # pvdisplay /dev/dsk/c7t2d0 # # --- Physical volumes --- # # PV Name /dev/dsk/c7t2d0 # # PV Name /dev/dsk/c2t2d0 Alternate Link # # ... # # # # As a result of this, a pvdisplay(1M) on the alternate link device # # files gives information about the same disk. # # # # # # Examples # # + To create a complete picture of your Logical Volume Manager # # system configuration, execute the following commands: # # # # # LVMcollect > LVMcollect.out # # # LVMcollect -v > LVMcollect.v.out # # # # You may want to print this information as a reference. # # # # + When you only want to see the logical volume information: # # # # # LVMcollect -p4 # # # # + To see logical volum information for a specific volume group: # # # # # LVMcollect -p4 /dev/vg_data # # # # + To get help information, issue the following command: # # # # # LVMcollect ? # # # # Warnings # # + All the physical volumes should be on-line, and all volume groups # # should be activate while scanning the Logical Volume Manager (LVM) # # system configuration. # # In order to account for the usage of the respective logical volumes # # and/or hard disk sections, it is also recommended to have all file # # systems mounted and all swap space enabled before you do a # # configuration scan. # # # # + This LVMcollect script was developed for the HP-UX release 10 on the # # on the HP 9000 Series 700 & 800 systems. Another version of the # # script is available for HP-UX release 9 (S800 only). # # # # + Output is not limited to 80 characters per line. You may want to use # # the fold(1) command to print the date, for example: # # # # # cat LVMcollect.v.out | fold | pr | lp -onb -o2 -otl66 # # # # Author # # Peter Van Giel Hewlett-Packard Country Response Center Belgium # # # # I welcome electronic mail from any users with comments, suggestions, # # or bug fixes: petervg@belgium.hp.com # # # # Files # # /tmp/LVMcollect.log Log file # # /tmp/LVMcollect. Temporary file, automatically cleaned up. # # /tmp/sh.<#> Temporary files for here documents. # # # # See also # # Solving HP-UX Problems: "How to Create the Picture of Your LVM System # # Configuration"

# # # ############################################################################### # While LVM provides desirable flexibility on your HP-UX system, it also adds # a level of complexity for system administration. Be sure that you safeguard # your LVM configuration. # # Because logical volumes (the LVM equivalent of a disk section or a partition) # can be part of a disk, part of several disks, an entire disk, several entire # disks, singly and doubly mirrored (or not mirrored at all), used for file # systems, swap space, or raw data areas, and altered in size, it is more # important than ever to have a complete and accurate view of how your system # is configured (how the various logical volumes and disk sections are being # used). # # An accurate picture of how your system is configured will help you to avoid # (and more quickly solve) LVM problems. The time you spend in assembling this # information can save you a lot of time when you are troubleshooting LVM # related problems. # # Some LVM-problems, prevent you from booting your system. Therefore, be sure # to have a printed copy of this information. If you keep it electronically # (on your system), and you can't boot the system, you won't be able to # retrieve the information you have gathered. When keeping the copy on-line, # make sure to put it in the root file system so that it can be addressed in # maintenance mode. ############################################################################### ############################################################################### # # Function definitions. # ############################################################################### ############################################################################### f_Header() { # Display an header giving additional information and warnings. # # The script revision number and run time are displayed. The user is # warned that all the physical volumes should be on-line to create an # accurate picture of the Logical Volume Manager system configuration. echo "${SEPARATOR2}" echo "******* *******" echo "******* LOGICAL VOLUME MANAGER (LVM) SYSTEM CONFIGURATION *******" echo "******* *******" echo "******* Response Center Belgium - Peter Van Giel *******" echo "******* *******" echo "${SEPARATOR2}" # Determine the revision number of the script. set -- $(what ${FULL_SCRIPT_NAME} | sed -e '/Revision/!d'); REVISION_NUMBER=$* echo ${REVISION_NUMBER} # Display the time that the script is ran. RUN_TIME=`date` echo "\nRun time ${SCRIPT_NAME}: ${RUN_TIME}" # Display warning message. echo "\n\nWARNING: All the physical volumes should be on-line while scanning" echo " the Logical Volume Manager (LVM) system configuration." } f_Index() { # Display the index to show what information will be retrieved. echo "\n\n${SEPARATOR}\n" echo "*****" echo "INDEX" echo "*****\n\n" echo "Part 1: SYSTEM CONFIGURATION" echo "Part 2: VOLUME GROUPS" echo "Part 3: PHYSICAL VOLUME GROUPS" echo "Part 4: LOGICAL VOLUMES" echo "Part 5: PHYSICAL VOLUMES" echo "Part 6: FILE SYSTEMS AND SWAP SPACE" echo "Part 7: ROOT / PRIMARY SWAP / DUMPS / KERNEL CONFIGURATION" echo "Part 8: LVM DEVICE FILES" echo "Part 9: OTHER" } f_Usage() { # Display a message giving information about the usage of LVMcollect. cat <&1 | \ grep -i pvdisplay > /dev/null 2>&1 if [ $? -ne 0 ] then # The disk is a physical volume PV="yes" # Check if the physical volume is bootable. A physical volume # is assumed to be bootable if it contains a LIF area, and the # LIF area contains the initial system loader (ISL). This is not # full proof, but it will give a good indication in the normal # cases. For more information about the LIF area, see the verbose # output of LVMcollect. lifls /dev/dsk/${DEVNAME} 2> /dev/null | \ grep -i isl > /dev/null 2>&1 if [ $? -eq 0 ] then # Bootable PV BOOTABLE_PV="bootable" else # Non-bootable PV BOOTABLE_PV="" fi # Determine if this is a physical volume link pvdisplay /dev/dsk/${DEVNAME} | grep -i 'Using Primary Link' > /dev/null if [ $? -eq 0 ] then PV_Link="yes" else PV_Link="no" fi else # The disk is not recognized as a physical volume. PV="no" BOOTABLE_PV="" PV_Link="n/a" fi # Filter out the hard disks, no information needs to be displayed for # other disk devices like CD-ROM's and cartridge tapes. # Cartridge tape drives and CD-ROM's may not respond nicely # to the diskinfo(1M) command ! diskinfo /dev/rdsk/${DEVNAME} > ${TEMPFILE} 2> /dev/null if [ $? -eq 0 ] then set -- $(cat ${TEMPFILE} | sed -e '/product id/!d'); PRODUCT_ID=$3 set -- $(cat ${TEMPFILE} | sed -e '/size/!d'); SIZE=$2 # Product id does not return nice for CD-ROM, spaces ! Print out # separated so that only the first part of the product id is # printed. echo ${DEVNAME} ${HW_PATH} ${PRODUCT_ID} `expr ${SIZE} / 1024` ${PV} | \ awk '{printf " %9s %9s %-12s %6d %-3s ", $1, $2, $3, $4, $5}' if [ "${BOOTABLE_PV}" != "" ] then echo ${BOOTABLE_PV} ${PV_Link} | awk '{printf "%8s %-3s\n", $1, $2}' else echo ${PV_Link} | awk '{printf " %-3s\n", $1}' fi else echo ${DEVNAME} | awk '{printf " %9s >> Error: Device is not a hard disk or is unavailable. <<\n", $1}' fi rm -f ${TEMPFILE} done echo "\n Note: All disk devices are listed here, not only hard disks." # Determine if the optional LVM mirroring software is installed. echo echo echo "LVM mirroring software" echo "**********************" echo if [ -f "/sbin/lvsync" ] then MIRROR="yes" echo " LVM mirroring software MirrorDisk/UX (B2491A) is installed." else MIRROR="no" echo " LVM mirroring software MirrorDisk/UX (B2491A) is NOT installed." fi } f_VolumeGroups() { ########################################################################### # Part 2: The Volume Groups on Your System # -------------------------------- # The f_VolumeGroups() function will help you identify the volume # groups on your system, and for each volume group: # # + The physical volumes associated with the volume group. # # + The volume group capacity: total, allocated, and free disk # space expressed in Mbytes and in physical extents. # # + The volume group's physical extent size. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "**********************" echo "Part 2: VOLUME GROUPS" echo "**********************" # Identify the volume groups and physical volumes. # Retrieve more information about each volume group: physical volumes, disk # space usage, physical extent size. vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo "\n\nVolume Group: ${VG_NAME}" echo "*************\n" # List all physical volumes in the volume group. echo " Physical Volumes:" echo vgdisplay -v ${VG_NAME} | grep -i name | grep -iv lv | \ grep -iv pvg | sed -e 1d | sed -e 's/.*\(\/.*\/.*\/.*\)/\1/' | \ sort -u -k 1,1 | sed -e 's/^/ /' echo # Get disk space information for the volume group. PE_SIZE=`vgdisplay ${VG_NAME} | grep 'PE Size' | \ sed -e 's/^[^0-9]*\([0-9][0-9]*\)[ ]*/\1/'` TOTAL_PE=`vgdisplay ${VG_NAME} | grep 'Total PE' | \ sed -e 's/^[^0-9]*\([0-9][0-9]*\)[ ]*/\1/'` ALLOC_PE=`vgdisplay ${VG_NAME} | grep 'Alloc PE' | \ sed -e 's/^[^0-9]*\([0-9][0-9]*\)[ ]*/\1/'` FREE_PE=`vgdisplay ${VG_NAME} | grep 'Free PE' | \ sed -e 's/^[^0-9]*\([0-9][0-9]*\)[ ]*/\1/'` echo " Volume group disk space usage:" echo echo `expr ${TOTAL_PE} \* ${PE_SIZE}` ${TOTAL_PE} | \ awk '{printf " Total : %5d Mbytes %5d PE\n", $1, $2}' echo `expr ${ALLOC_PE} \* ${PE_SIZE}` ${ALLOC_PE} | \ awk '{printf " Allocated: %5d Mbytes %5d PE\n", $1, $2}' echo `expr ${FREE_PE} \* ${PE_SIZE}` ${FREE_PE} | \ awk '{printf " Free : %5d Mbytes %5d PE\n\n", $1, $2}' echo ${PE_SIZE} | \ awk '{printf " PE size : %5d Mbytes\n", $1}' done } f_PhysicalVolumeGroups() { ########################################################################### # Part 3: The Physical Volume Groups on Your System # ----------------------------------------- # Physical volume groups are subgroups of LVM disks (physical # volumes) within a volume group. An ASCII file, /etc/lvmpvg # contains all the mapping information for the physical volume # group, but the mapping is not recorded on the disk. # # This part of the procedure will help you identify: # # + For each volume group, the physical volume groups. # # + For each physical volume group, the physical volumes. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "*******************************" echo "Part 3: PHYSICAL VOLUME GROUPS" echo "*******************************" if [ -f /etc/lvmpvg ] then # For each volume group, show the physical volumes defined. # NOTE: The existance of the /etc/lvmpvg file doesn't imply that # there are physical volume groups defined for each volume # group. Catch the abscence and display an appropriate message. vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo "\n\nVolume Group: ${VG_NAME}" echo "*************\n" rm -f ${TEMPFILE} > /dev/null 2>&1 vgdisplay -v ${VG_NAME} | \ sed -n -e '/Physical volume groups/,$p' | \ tee ${TEMPFILE} | \ sed -e '1d' \ -e '$d' \ -e '$d' \ -e 's/.*PVG Name[ ]*/ Physical volume group: /' \ -e 's/.*PV Name[ ]*/ /' # The existance of the '/etc/lvmpvg' file doesn't imply that there # are physical volume groups defined for each volume group. Catch # the abscence and display an appropriate message. if [ ! -s ${TEMPFILE} ] then echo "No physical volume groups were defined for this volume group." fi done else # The '/etc/lvmpvg' file is missing. echo "\n\nNo physical volume groups were defined, see lvmpvg(4)." fi } f_LogicalVolumes() { ########################################################################### # Part 4: The Logical Volumes on Your System # ---------------------------------- # In part 2 of the procedure you identified the volume groups that # are defined on your system. These are pools of disk space from # which logical volumes (the LVM equivalent of disk sections) are # created. # # The f_LogicalVolumes() function will help you identify: # the logical volumes on your system, which volume groups they are # part of, how big they are, the logical volume permissions, bad # block allocation policy, allocation policy, status, whether they # are mirrored (single, or double) or not mirrored at all, # consistency recovery, scheduling policy, and information about # disk striping: number of disks in the stripe, stripe size. # # Arguments passed: # $2 Can be the name of a valid volume group. In this case # limit the output of f_LogicalVolumes() to only that # volume group. This argument can only be passed when the # -p4 option is used. # An invalid argument is ignored. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "************************" echo "Part 4: LOGICAL VOLUMES" echo "************************" VG=$2 if [ "${VG}" != "" ] then # Check if volume exists, else ignore argument vgdisplay ${VG}> /dev/null 2>&1 if [ $? -eq 0 ] then echo "\n\nWarning: Output limited to volume group ${VG}." else echo "f_LogicalVolumes(): Volume group '${VG}' does not exist, ignoring argument." >> ${LOGFILE} VG="" fi fi vgdisplay ${VG} | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo "\n\nVolume Group: ${VG_NAME}" echo "*************\n" echo " Logical Volume Size PE B Alloc. Status Mirroring Stripes" echo " Name Mbytes RM B # CR S # Size" echo " ========================================================================" # Retrieve more information for each logical volume. vgdisplay -v ${VG_NAME} | grep -i 'lv name' | sed -e 's/.*\/.*\/.*\/\(.*\)/\1/' | \ while read LV_NAME do # Determine the logical volume's size. set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/LV Size.*[0-9][0-9]*/!d'); LV_SIZE=$4 # Determine the logical volume's permissions. lvdisplay ${VG_NAME}/${LV_NAME} | grep -i "LV Permission" | \ grep -i write > /dev/null if [ $? -eq 0 ] then PERMISSION="rw" else PERMISSION="r" fi # Determine if bad block relocation is enabled for the logical # volume. lvdisplay ${VG_NAME}/${LV_NAME} | grep -i "Bad block" | \ grep on > /dev/null if [ $? -eq 0 ] then # Bad block relocation enabled BAD_BLOCK="Y" else # Bad block relocation disabled BAD_BLOCK="N" fi # Determine the allocation policy of the logical volume. set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/Allocation/!d' \ -e 's/contiguous/C/' -e 's/strict/S/'); ALLOCATION=$2 # Determine the status of the logical volume. set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/LV Status/!d'); STATUS=$3 # Determine the number of mirror copies of the logical volume. set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/Mirror copies/!d'); MIRROR=$3 # Determine the mirror consistency recovery mode of the logical # volume. set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/Consistency Recovery/!d'); CONS_REC=$3 # Determine the scheduling policy of the logical volume. set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/Schedule/!d' \ -e 's/parallel/par/' -e 's/sequential/seq/' \ -e 's/striped/str/'); SCHEDULE=$2 # Determine the number of disk striped accross. set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/Stripes/!d'); STRIPES=$2 # Determine the stripe size (in Kbytes) set -- $(lvdisplay ${VG_NAME}/${LV_NAME} | sed -e '/Stripe Size/!d'); STRIPE_SIZE=$4 # Display the logical volume's information. if [ `echo ${LV_NAME} | wc -c` -le 16 ] then # Print all information on one line. echo ${LV_NAME} ${LV_SIZE} ${PERMISSION} ${BAD_BLOCK} | \ awk '{ printf " %15s %5d %2s %1s", $1, $2, $3, $4 }' echo ${ALLOCATION} ${STATUS} ${MIRROR} ${CONS_REC} ${SCHEDULE} | \ awk '{ printf " %7s %15s %1s %5s %3s", $1, $2, $3, $4, $5 }' echo ${STRIPES} ${STRIPE_SIZE} | \ awk '{ printf " %3d %4d\n", $1, $2}' else # If the logical volume name is longer than 15 characters, # print it on a seperate line. echo ${LV_NAME} | awk '{printf " %s\n", $1}' echo ${LV_SIZE} ${PERMISSION} ${BAD_BLOCK} | \ awk '{ printf " %5d %2s %1s", $1, $2, $3}' echo ${ALLOCATION} ${STATUS} ${MIRROR} ${CONS_REC} ${SCHEDULE} | \ awk '{ printf " %7s %15s %1s %5s %1s", $1, $2, $3, $4, $5 }' echo ${STRIPES} ${STRIPE_SIZE} | \ awk '{ printf " %3d %4d\n", $1, $2}' fi done # echo # echo " (PERM) Access Permissions (BB) Bad Block Relocation Policy (#) Number" # echo " of Mirrors (CR) Consistency Recovery Mode (S) Scheduling of Disk Writes" # cat < /dev/null if [ $? -eq 0 ] then set -- $(echo ${LINE}); PV_NAME=$1 ALTLINK="Alternate Link" else PV_NAME=${LINE} ALTLINK="" fi echo "\n\nPhysical Volume: ${PV_NAME} ${ALTLINK}" echo "****************" if [ "${ALTLINK}" != "" ] then # Display additional information about Alternate Link echo pvdisplay ${PV_NAME} | sed -n -e '1,2p' | sed -e 's/^/ /' cat <'. EOF else # Get disk space information for the physical volume. set -- $(pvdisplay ${PV_NAME} | sed -e '/PE Size.*[0-9][0-9]*/!d'); PE_SIZE=$4 set -- $(pvdisplay ${PV_NAME} | sed -e '/Total PE.*[0-9][0-9]*/!d'); TOTAL_PE=$3 set -- $(pvdisplay ${PV_NAME} | sed -e '/Allocated PE.*[0-9][0-9]*/!d'); ALLOC_PE=$3 set -- $(pvdisplay ${PV_NAME} | sed -e '/Free PE.*[0-9][0-9]*/!d'); FREE_PE=$3 pvdisplay ${PV_NAME} | grep -i 'alternate link' > /dev/null if [ $? -eq 0 ] then echo "\n *** Alternate Link available ***" fi echo echo " Physical volume disk space usage:" echo echo `expr ${TOTAL_PE} \* ${PE_SIZE}` ${TOTAL_PE} | \ awk '{printf " Total : %5d Mbytes %5d PE\n", $1, $2}' echo `expr ${ALLOC_PE} \* ${PE_SIZE}` ${ALLOC_PE} | \ awk '{printf " Allocated: %5d Mbytes %5d PE\n", $1, $2}' echo `expr ${FREE_PE} \* ${PE_SIZE}` ${FREE_PE} | \ awk '{printf " Free : %5d Mbytes %5d PE\n", $1, $2}' echo ${PE_SIZE} | \ awk '{printf " PE size : %5d Mbytes\n", $1}' echo # List the logical volumes that have extents allocated in the # physical volume. echo " Distribution of physical volume:" echo pvdisplay -v ${PV_NAME} | grep 'LE of LV' pvdisplay -v ${PV_NAME} | sed -n -e '/^ \//p' fi done } f_FS_SW() { ########################################################################### # Part 6: File Systems and Swap Space on Your System # ------------------------------------------ # The f_FS_SW() function gives an overview of the file systems # and swap space configured in the system. With this information # you can determine what the different logical volumes (and hard # sections) are being used for. # # Unfortunately, there is no way to determine which logical # volumes (and/or hard sections) are being used for raw I/O or # those that have currently unmounted file systems. The same is # true for non-activated swap space. You will have to be # familiar with the operations on the system in order to determine # what these are being used for (if anything at all). # # No HP-UX commands can explicitely list logical volumes and/or # disk sections that contain raw data. Therefore, you might need # to devise a means to keep track of logical volumes and/or disk # sections used for raw data. For example, when you create a # logical volume containing raw data, use the '-n' option to the # lvcreate(1M) command to give your logical volume an easily # recognizable name, such as /dev/vg00/lab_data, so that you can # identify them later on. Information about which logical volumes # and/or sections that contain raw data, can also be put in the # /etc/fstab file. # # The following information is displayed: # # + Mounted file systems: # file system, total, used, and available space, percentage # used, mount point # # + Activated swap space ########################################################################### echo "\n\n${SEPARATOR}\n" echo "************************************" echo "Part 6: FILE SYSTEMS AND SWAP SPACE" echo "************************************" # There is no way to determine which logical volumes are being used for raw # I/O and those that have currently unmounted file systems. You will have # to be familiar with the operations on the system in order to determine # what these are being used for (if anything at all). The same problem # exists for non-LVM disks. # # Information about these logical volumes and/or disk sections can be put # as a comment in the '/etc/fstab' file. When creating a logical # volume to contain raw data, give the logical volume an easily # recognizable name. # Print a warning message. cat <&1 | sed -e 's/^/ /' echo "\n\nKernel configuration for primary swap and dump" echo "**********************************************\n" echo "*system_data/s" | adb /stand/vmunix /dev/kmem | grep swap | grep -v maxswapchunks echo "*system_data/s" | adb /stand/vmunix /dev/kmem | grep dump echo "\n\nLVM related system parameters" echo "*****************************\n" set -- $(echo 'maxvgs/D' | adb /stand/vmunix /dev/kmem | sed -e '/maxvgs:.*[0-9][0-9]*/!d') MAXVGS=$2 echo "Maximum number of volume groups (maxvgs) = ${MAXVGS}\c" if [ ${MAXVGS} -eq 10 ] then echo " (default value)" else echo fi } f_DeviceFiles() { ########################################################################### # Part 8: LVM Device Files # ---------------- # The f_DeviceFiles() function gives a listing of the LVM device # files for each volume group that is recognized on the system. # # The major number is alway 64. # # The minor number of the device file contains the following # information: # # 0x##00## # -- -- # | |_ hexadecimal logical volume number (1..255) # | (00 is reserved for the group file) # |_____ hexadecimal volume group number (0..255) # # You need this information to recreate the device files if they # were removed by mistake. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "*************************" echo "Part 8: LVM DEVICE FILES" echo "*************************" # List all LVM related device files. vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo "\n\nVolume Group: ${VG_NAME}" echo "*************\n" # List all device files in the volume group, sorted according to the # minor number. ll ${VG_NAME} | sed -e '1d' | sort +5 -6 done } f_Other() { ########################################################################### # Part 9: Other # ----- # The f_Other() function gives information about topics that were # not included in the preceding functions. The following # information is retrieved: # # + Volume group configuration backups: # for each of the volume groups there is a check if the # /etc/lvmconf/.conf file exists. If it doesn't, # we assume that no volume group configuration backup was # made for this volume group, and the user is given a warning. # We test here for the name of the default backup file # (another filename can be specified with the '-f' option of # the vgcfgbackup(1M) command), so the procedure is not full # proof. Also there is no check if the backup is up to date. # # + Version information is displayed for the commands # vgcfgbackup(1M) and vgcfgrestore(1M), both for the verions # under /sbin and /usr/sbin. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "**************" echo "Part 9: OTHER" echo "**************" echo "\n\nVolume group configuration backups" echo "**********************************\n" # For each volume group determine if there is a backup of the volume # group configuration. vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do if [ -f /etc/lvmconf/`basename ${VG_NAME}`.conf ] then ll /etc/lvmconf/`basename ${VG_NAME}`.conf else BACKUP_FILE=`basename ${VG_NAME}` cat <>) allow you to jump from volume group to volume # group. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "**********************" echo "Part 2: VOLUME GROUPS" echo "**********************" # Give an overview of the volume groups found on the system. echo "\n\nVolume Groups:" echo "**************\n" vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo " ${VG_NAME}" done # Display information about each volume group. echo "\n\nDetailed information for each volume group:" echo "*******************************************" vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo echo "________________" echo ">> Volume group: ${VG_NAME}" echo "________________" echo echo "Executing: 'vgdisplay -v ${VG_NAME}'" echo vgdisplay -v ${VG_NAME} done } f_d_PhysicalVolumeGroups() { ########################################################################### # Part 3: The Physical Volume Group on Your Systems (verbose mode) # ----------------------------------------- # The f_d_PhysicalVolumeGroups() function lists the /etc/lvmpvg # file, showing the configuration of the physical volume groups # on the system. If this file does not exist, no physical volume # groups were defined. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "*******************************" echo "Part 3: PHYSICAL VOLUME GROUPS" echo "*******************************\n\n" if [ -f /etc/lvmpvg ] then echo "Executing: 'cat /etc/lvmpvg'\n" cat /etc/lvmpvg else echo "No physical volume groups were defined." fi } f_d_LogicalVolumes() { ########################################################################### # Part 4: The Logical Volumes on Your System (verbose mode) # ---------------------------------- # The f_d_LogicalVolumes() function will help you identify the # logical volumes on your system. The following information is # returned: # # + Logical Volumes: # for each volume group, a list of the logical volumes # belonging to this volume group. # # + Detailed information for each logical volume: # for each logical volume, the verbose output of the # lvdisplay(1M) command. # # Search marks (>>) allow you to jump from logical volume to # logical volume. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "************************" echo "Part 4: LOGICAL VOLUMES" echo "************************" # Give an overview of the volume groups found on the system. echo echo echo "Logical Volumes:" echo "****************" vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo "\n Volume Group: ${VG_NAME}" # Get a list of logical volumes in this volume group. LV_NAMES=`vgdisplay -v ${VG_NAME} | grep -i 'lv name' | \ sed -e 's/.*\(\/.*\/.*\/.*\)/\1/'` for LV_NAME in ${LV_NAMES} do echo " ${LV_NAME}" done done # Display information about each logical volume. echo "\n\nDetailed information for each logical volume:" echo "*********************************************" vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do # Get a list of LV's in this VG LV_NAMES=`vgdisplay -v ${VG_NAME} | grep -i 'lv name' | \ sed -e 's/.*\(\/.*\/.*\/.*\)/\1/'` for LV_NAME in ${LV_NAMES} do echo "\n__________________" echo ">> Logical volume: ${LV_NAME}" echo "__________________\n" echo "Executing: 'lvdisplay -v ${LV_NAME}'\n" lvdisplay -v ${LV_NAME} done done } f_d_PhysicalVolumes() { ########################################################################### # Part 5: The Physical Volumes on Your System (verbose mode) # ----------------------------------- # The f_d_PhysicalVolumes() funstion will help you identify the # physical volumes on your system. The following information is # returned: # # + Physical Volumes: # for each volume group, a list of physical volumes belonging # to this volume group. # # + Detailed information for each physical volume: # for each physical volume the verbose output of the # pvdisplay(1M) command. # # Search marks (>>) allow you to jump from physical volume to # physical volume. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "*************************" echo "Part 5: PHYSICAL VOLUMES" echo "*************************" # Give an overview of the physical groups found on the system. echo "\n\nPhysical Volumes:" echo "*****************" vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo "\n Volume Group: ${VG_NAME}" vgdisplay -v ${VG_NAME} | grep -i 'pv name' | \ sed -e 's/.*\(\/.*\/.*\/.*\)/\1/' | sort -u -k 1,1 | \ while read PV_NAME do echo " ${PV_NAME}" done done # Display information about each physical volume. echo "\n\nDetailed information for each physical volume:" echo "**********************************************" vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do # Get a list of PV's in this VG. vgdisplay -v ${VG_NAME} | grep -i 'pv name' | \ sed -e 's/.*\(\/.*\/.*\/.*\)/\1/' | sort -u -k 1,1 | \ while read LINE do # Determine whether we are dealing with Physical Volume Links echo ${LINE} | grep 'Alternate Link' > /dev/null if [ $? -eq 0 ] then set -- $(echo ${LINE}); PV_NAME=$1 ALTLINK="Alternate Link" else PV_NAME=${LINE} ALTLINK="" fi echo "\n___________________" echo ">> Physical volume: ${PV_NAME} ${ALTLINK}" echo "___________________\n" if [ "${ALTLINK}" != "" ] then # Display additional information about Alternate Link echo pvdisplay ${PV_NAME} | sed -n -e '1,2p' | sed -e 's/^/ /' cat <'. EOF else echo "Executing: 'pvdisplay -v ${PV_NAME}'\n" pvdisplay -v ${PV_NAME} fi done done } f_d_FS_SW() { ########################################################################### # Part 6: File Systems and Swap Space on Your System (verbose mode) # ------------------------------------------ # The f_d_FS_SW() function gives more information about the usage # of the logical volumes and/or disk sections. The output of the # bdf(1M) command gives an overview of the file systems, the # output of the swapinfo(1M) command gives an overview of the # swap space usage. The contents of the /etc/fstab file is # included to give more information about logical volumes and/or # disk sections that are used for raw data (only if an appropriate # comment was added to this file). It may also give information # about currently unmounted file systems or inactivated swap # swace. # # Search marks (>>) allow you to quickly locate the needed # information. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "************************************" echo "Part 6: FILE SYSTEMS AND SWAP SPACE" echo "************************************" # Print a warning message. cat <> Mounted file systems:" echo "________________________\n" echo "Executing: 'bdf'\n" bdf # Display a list of the currently activated swap space. echo "\n\n________________________" echo ">> Activated swap space:" echo "________________________\n" echo "Executing: 'swapinfo -m'\n" swapinfo -m echo "\n\n___________________" echo ">> /etc/fstab file:" echo "___________________\n" echo "Executing: 'cat /etc/fstab'\n" cat /etc/fstab } f_d_KernelConfiguration() { ########################################################################### # Part 7: Root / Primary Swap / Dumps / Kernel (verbose mode) # Configuration # ------------------------------------ # The f_d_KernelConfiguration() function will help you to # identify the root, primary swap, and dump logical volumes, and # the LVM related system parameters. The following information # is returned: # # + Logical volume manager definitions for root, primary swap # and dumps: the information given is the output of the # lvlnboot(1M) command in verbose mode. # # + Kernel generation file: # The file that was used to generated the kernel. It is # extracted from /stand/vmunix which is assumed to be the # running kernel. # # Search marks (>>) allow you to quickly locate the needed # information. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "***********************************************************" echo "Part 7: ROOT / PRIMARY SWAP / DUMPS / KERNEL CONFIGURATION" echo "***********************************************************" echo "\n\n________________________________________________________________________" echo ">> Logical volume manager definitions for root, primary swap, and dumps:" echo "________________________________________________________________________\n" echo "Executing: 'lvlnboot -v 2>&1'\n" lvlnboot -v 2>&1 echo "\n\n__________________________" echo ">> Kernel generation file:" echo "__________________________\n" echo "*system_data/s" | adb /stand/vmunix /dev/kmem | sed -e 's/shminfo+2B8:[ ]*//' } f_d_VolumeGroupBackups() { ########################################################################### # Part 8: Volume Group Configuration Backups # ---------------------------------- # The f_d_VolumeGroupBackups() function gives more detailed # information about the volume group configuration backups. If # no backup exists, the user is warned. # # Search marks (>>) allow you to quickly locate the needed # information. ########################################################################### echo "\n\n${SEPARATOR}\n" echo "*******************************************" echo "Part 8: VOLUME GROUP CONFIGURATION BACKUPS" echo "*******************************************" # Give an overview of the volume groups found on the system. echo "\n\nVolume Groups:" echo "**************\n" vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo " ${VG_NAME}" done # List configuration information saved in the volume group configuration # backup. vgdisplay | grep 'VG Name' | sed -e 's/VG Name[ ]*//' | \ while read VG_NAME do echo echo echo "________________" echo ">> Volume group: ${VG_NAME}" echo "________________" echo BACKUP_FILE=`basename ${VG_NAME}` if [ -f /etc/lvmconf/${BACKUP_FILE}.conf ] then echo "Executing: 'vgcfgrestore -n ${VG_NAME} -l'\n" vgcfgrestore -n ${VG_NAME} -l echo "\nExecuting: 'll /etc/lvmconf/${BACKUP_FILE}.conf'\n" ll "/etc/lvmconf/${BACKUP_FILE}.conf" else cat <> Physical Volume: /dev/dsk/${DEVNAME} (H/W Path: ${HW_PATH})" echo "___________________\n" pvdisplay /dev/dsk/${DEVNAME} 2> /dev/null | grep -i "using primary link" > /dev/null if [ $? -eq 0 ] then # Display additional information about Alternate Link pvdisplay /dev/dsk/${DEVNAME} | sed -n -e '1,2p' | sed -e 's/^/ /' cat <'. EOF else lifls /dev/rdsk/${DEVNAME} > /dev/null 2>&1 if [ $? -eq 0 ] then echo "A LIF area was found on this disk, it contains the following files:\n" lifls -l /dev/rdsk/${DEVNAME} | sed 's/^/ /' AUTO_FILE=`lifcp /dev/rdsk/${DEVNAME}:AUTO - 2> /dev/null` if [ $? -eq 0 ] then echo "\nContents of the AUTO file:\n" echo " ${AUTO_FILE}" fi else echo "No LIF area was found on this disk." fi fi done } f_d_Other() { ########################################################################### # Part 10: Other # ----- # The f_d_Other() function gives some additionale information # not included in the previous parts of the script. It shows # information from the /etc/lvmtab file, and the /etc/lvmrc file. ########################################################################### echo echo echo "${SEPARATOR}" echo echo "***************" echo "Part 10: OTHER" echo "***************" echo "\n\n____________________" echo ">> /etc/lvmtab file:" echo "____________________\n" if [ -f /etc/lvmtab ] then echo "Executing: 'strings /etc/lvmtab'\n" strings /etc/lvmtab fi echo "\n\n____________________" echo ">> /sbin/lvmrc file:" echo "____________________\n" echo "Executing: 'cat /sbin/lvmrc'\n" cat /sbin/lvmrc echo "\n\n____________________" echo ">> /etc/lvmrc file:" echo "____________________\n" echo "Executing: 'cat /etc/lvmrc'\n" cat /etc/lvmrc echo echo echo "${SEPARATOR}" } ############################################################################### ############################################################################### # # Script main body. # ############################################################################### ############################################################################### # Initialize shell variables. PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin:/bin:/etc export PATH SCRIPT_NAME=`basename $0` FULL_SCRIPT_NAME=$0 TEMPFILE="/tmp/${SCRIPT_NAME}.$$" LOGFILE="/tmp/${SCRIPT_NAME}.log" SEPARATOR="..............................................................................." SEPARATOR2="*******************************************************************************" # Put message in log file echo "======= " `date "+%d/%m/%y %X %z"` " Begin (pid: $$)" >> ${LOGFILE} echo "Command: $0 $*" >> ${LOGFILE} # Only the super-user can successfully run this script. id | grep '(root)' > /dev/null if [ $? -ne 0 ] then echo "\nSorry, you must be super-user to run ${SCRIPT_NAME}.\n" exit 1 fi # Check the operating system release. # Set up redirection of stderr. exec 2>>${LOGFILE} # Provide cleanup of temporary file when interrupted. trap "echo '\n\nInterrupted, cleaning up.\n'; rm -f ${TEMPFILE} > /dev/null 2>&1;echo '======= ' `date '+%d/%m/%y %X %z'` ' Interrupted\n' >> ${LOGFILE}; exit 1" 1 2 15 # Determine if Logical Volume Manager is installed. if [ ! -f "/sbin/vgcfgbackup" ] then echo "\n${SCRIPT_NAME}: LVM software not installed.\n" exit 1 fi # Determine if the /etc/lvmtab file is present on the system. # The file /etc/lvmtab contains information about how physical volumes are # grouped on your system (which volume groups contain which disks). Many # LVM commands rely on /etc/lvmtab, so it is important not to rename it or # destroy it. if [ ! -f /etc/lvmtab ] then echo "\nThe /etc/lvmtab file is not present on the system. Load the file" echo "from backup or try to rebuild it using the vgscan(1M) command.\n" exit 1 fi # Determine whether to execute all or selected parts of the script. if [ $# -eq 0 ] then # Run all parts of the script. f_Header f_Index f_SystemConf f_VolumeGroups f_PhysicalVolumeGroups f_LogicalVolumes f_PhysicalVolumes f_FS_SW f_KernelConfiguration f_DeviceFiles f_Other echo ${SEPARATOR} else # Run a selected part of the script or retrieve detailed information. if [ $# -ge 1 ] then case $1 in -p1) f_Header f_SystemConf ;; -p2) f_Header f_VolumeGroups ;; -p3) f_Header f_PhysicalVolumeGroups ;; -p4) f_Header f_LogicalVolumes $* ;; -p5) f_Header f_PhysicalVolumes ;; -p6) f_Header f_FS_SW ;; -p7) f_Header f_KernelConfiguration ;; -p8) f_Header f_DeviceFiles ;; -p9) f_Header f_Other ;; -v) f_d_Header f_d_Index f_d_SystemConf f_d_VolumeGroups f_d_PhysicalVolumeGroups f_d_LogicalVolumes f_d_PhysicalVolumes f_d_FS_SW f_d_KernelConfiguration f_d_VolumeGroupBackups f_d_LIFinfo f_d_Other ;; *) f_Usage ;; esac else f_Usage fi fi # If we make it to here, the script should have executed alright. rm -rf ${TEMPFILE} > /dev/null 2>&1 # Put message in log file echo "======= " `date "+%d/%m/%y %X %z"` " End\n" >> ${LOGFILE} exit 0