Quickly Grow EMC Celerra Filesystem
As we all know, Celerra and its kin can get a bit annoying with their “filesystem over 90%” warning emails. Enabling the “autoextend” feature for the filesystems is one option, but if you are a control freak like me, you want to control what to extend, when and by how much.
So here is a simple script that can be ran on the console. The script will check on the current size of the filesystem that exceeded the threshold and it will add just enough space to take it a couple of percent below the threshold. The filesystem extend operation is launched in the background, so it takes a lot less of your time than using the Unisphere GUI. This script has been tested on VNX.
#!/bin/ksh # igor<at>krazyworks.com # June 2013 # ---------------------------------------------------------------------------- # Use this script to grow a Celerra filesystem so utilization drops below # warning threshold. # ---------------------------------------------------------------------------- # if [ -z ] then echo -n "Enter filesystem name: " read filesystem_name else filesystem_name="" fi configure() { threshold=90 percent_buffer=2 percent_target=$(echo "scale=0;${threshold}-${percent_buffer}"|bc -l) if [ -z "${filesystem_name}" ] then echo "Filesystem name cannot be blank. Exiting..." ; exit 1 else filesystem_status=1 filesystem_status=$(/nas/bin/nas_fs -size ${filesystem_name} > /dev/null 2>&1 ; echo $?) if [ ${filesystem_status} -ne 0 ] then echo "Filesystem ${filesystem_name} does not exist. Exiting..." ; exit 1 fi fi } grow_fs() { percent_util=1 ; filesystem_size=1 ; filesystem_used=1 filesystem_size=$(/nas/bin/nas_fs -size ${filesystem_name} | grep ^total | awk '{print $3}') filesystem_used=$(/nas/bin/nas_fs -size ${filesystem_name} | grep ^total | awk '{print $9}') percent_util=$(echo "scale=0;${filesystem_used}*100/${filesystem_size}"|bc -l) if [ ${percent_util} -ge ${threshold} ] then filesystem_grow=$(echo "scale=0;${filesystem_size}-(${filesystem_used}*${percent_target}/${percent_util})"|bc -l) filesystem_grow_gb=$(echo "scale=0;${filesystem_grow}/1024"|bc -l) response="no" echo "${filesystem_name} shows ${percent_util}% utilization" echo "Will need to add ${filesystem_grow_gb}GB to take utilization down to ${percent_target}%" echo -n "Proceed? [y/n]: " read response case ${response} in y|yes) echo "Extending ${filesystem_name} by ${filesystem_grow_gb}GB" nohup /nas/bin/nas_fs -xtend "${filesystem_name}" size=${filesystem_grow}M > /dev/null 2>&1 & echo "The filesystem extend operation is running in background." ;; n|no) echo "Cancelling operation. Exiting..." exit 0 ;; *) echo "Response was not recognized. Exiting..." exit 1 ;; esac else echo "Filesystem ${filesystem_name} is below ${threshold}% threshold. No action required." exit 0 fi } # RUNTIME configure grow_fs