AIX LVM

AIX Logical Volume Manager

Resize Filesystem

Set the MYFS and MYFSSZ variables to reflect the filesystem (e.g. /opt) and target size in MB (e.g. 12288)..

export MYFS=/filesystem

export MYFSSZ=12288

Use the following scripts to check and resize...

Check Volume Group

Check whether there is enough free space in the Volume Group to fulfil the request..

/u01/dba/aix/chkvgspc.ksh ${MYFS} ${MYFSSZ}

#!/bin/ksh

# .............................................................................

#

# Name          /u01/dba/aix/chkvgspc.ksh

#

# Purpose       Check there is enough space in the parent Volume Group to

#               expand the specified filesystem to a specifified size (MB)

#

# Usage         /u01/dba/aix/chkvgspc.ksh /filesystem TargetSizeInMB

#

# HISTORY

#   Ver       Date         Who  Comments

#   --------  -----------  ---  -----------------------

#   01.00.00  13-Mar-2020  MPG  Created

#

# .............................................................................


VERSION="01.00.00 (13-Mar-2020 Build 1)"


echo "==============================================================================="

echo "$(basename $0) v${VERSION} "

echo "Volume Group Space Check"

echo "Started at $(date) on server $(hostname -s) by ${USER}"

echo "==============================================================================="

trap "echo \"\";echo \"===[ End of report ]===========================================================\"; exit" 0 1 2 15

echo ""


case $(uname) in

   AIX) ;;

   *)   echo "$(date +%H:%M:%S): ERROR: chkvgspc.ksh only runs on AIX"

        exit 1

        ;;

esac


if [ $# -ne 2 ]

then

   echo "$(date +%H:%M:%S): ERROR: Usage: chkvgspc.ksh /filesystem sizeinmb"

   exit 1

fi


MYFS=$1

MYFSSZ=$2


lvn=$(lsfs | grep ${MYFS}| awk '{ print $1 }' | cut -d/ -f3)

usb=$(lsfs | grep ${MYFS}| awk '{ print $5 }')

(( usm = ${usb} / 2048 ))

vgn=$(lslv ${lvn} | grep "VOLUME GROUP" | awk '{ print $6 }')

fre=$(lsvg ${vgn} | grep "FREE PPs" | awk '{ sub(/\(/,""); print $7 }')

(( ava = ${fre} + ${usm} ))

echo "*******************************************************"

echo "Target Size for ${MYFS} (${lvn}): ${MYFSSZ}"

echo "Available space in Volume Group (${vgn}) : ${ava}"

echo ${MYFSSZ} ${ava} | awk '{ if ($1 > $2) print "*** VG TOO SMALL!"; else print "*** OK"; }'

echo "*******************************************************"


exit 0

Resize

Only run this if the VG Check passed.

Run as 'root'...

lvn=$(lsfs | grep ${MYFS} | awk '{ print $1 }' | cut -d/ -f3) # Logical Volume Name

siz=$(lsfs | grep ${MYFS} | awk '{ print $5 }')               # Determine the current filesystem size in 512-byte blocks

(( siz = ${siz} / 2048 ))                                     # Convert to MB from 512-byte blocks

pps=$(lslv ${lvn} | grep "PP SIZE" | awk '{ print $6 }')      # Get Physical Partition (PP) size of Logical volume... 

(( lps = ${MYFSSZ} - ${siz} ))                                # How many MB need to be added

(( lps = ${lps} / ${pps} ))                                   # How many LPs to add (LP size is equal PP size)

extendlv ${lvn} ${lps}                                        # Extend LV by number of LPs calculated above

chfs -a size=${MYFSSZ}M ${MYFS}                               # Change Filesystem size

Resize Volume Group

To increase the size of a Volume Group you need to increase the number of Pysical Partitions (PPs) available to it, either by adding an additional disk (physical or LUN) or by increasing the size of the disk (only possible if the underlying storage is a LUN rather than a physical disk).