#!/bin/bash # version 1.2 # 20240626 IWT added XFS support # version 1.1 # 20180307 IWT added logger # echo ${1} ${2} # echo "lvextend -L +${1}G ${2}" # echo "resize_reiserfs -s +${1}G ${2}" if [[ -e /usr/sbin/ext2online ]] then ext2expand="/usr/sbin/ext2online" elif [[ -e /sbin/resize2fs ]] then ext2expand="/sbin/resize2fs" fi tmp=$(which logger 2>/dev/null) if [[ '0' == $? ]] then LOGGER=$(which logger) else LOGGER='echo' fi if [[ -z $1 || -z $2 ]] then echo "Usage: increasefs.ksh {size in Gigs} {location of lv}" echo "Example: 'increasefs.ksh 20 /dev/mirr01vg/fedoralv' increases the fedoralv by 20G" else if [[ -e $2 ]] then fstype=$(file -sL $2 | awk '{print $2}' | tr '[:upper:]' '[:lower:]') fssubtype=$(file -sL $2 | awk '{print $3}' | tr '[:upper:]' '[:lower:]') # fs=$(ls -l $2 | awk '{ print $11 }') # echo "fs=[${fs}]" # fstype=$( mount | grep $fs | awk '{ print $5 }') # echo "[$fstype]" if [[ $fstype == 'Linux' ]] then fstype=$(file -sL $2 | awk '{print $5}') fi if [[ $fstype == "reiserfs" ]] then echo "lvextend -L +${1}G ${2}" lvextend -L +${1}G ${2} echo "resize_reiserfs -s +${1}G ${2}" resize_reiserfs -s +${1}G ${2} dt=$(date '+%Y%m%d-%H%M') echo "${dt} $1 $2" >> /var/log/increasefs.log ${LOGGER} "increaseFS ${dt} $1 $2" elif [[ $fstype == "ext3" ]] || [[ $fstype == "ext4" ]] then echo "lvextend -L +${1}G ${2}" lvextend -L +${1}G ${2} echo "ext2online ${2}" $ext2expand ${2} tune2fs -r 10000 ${2} dt=$(date '+%Y%m%d-%H%M') echo "${dt} $1 $2" >> /var/log/increasefs.log ${LOGGER} "increaseFS ${dt} $1 $2" elif [[ $fstype == "sgi" ]] && [[ $fssubtype == "xfs" ]] then echo "lvextend -L +${1}G ${2}" lvextend -L +${1}G ${2} echo "xfs_growfs ${2}" xfs_growfs ${2} dt=$(date '+%Y%m%d-%H%M') echo "${dt} $1 $2" >> /var/log/increasefs.log ${LOGGER} "increaseFS ${dt} $1 $2" else echo "Unknown filesystem type" fi else echo "$2 does not exsist" fi fi