summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/checkXFSfrag.sh
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2015-02-12 21:55:59 (GMT)
committerBritney Fransen <brfransen@gmail.com>2015-02-12 21:55:59 (GMT)
commitfd00440460d6d5300d23fc5fafb0fccd18791f30 (patch)
tree35a83f4e84be1f35c39e9b605fef1c1b855d3985 /abs/core/LinHES-system/checkXFSfrag.sh
parent35cf94665cde31376946f7d0f46218d7cea893d8 (diff)
downloadlinhes_pkgbuild-fd00440460d6d5300d23fc5fafb0fccd18791f30.zip
linhes_pkgbuild-fd00440460d6d5300d23fc5fafb0fccd18791f30.tar.gz
linhes_pkgbuild-fd00440460d6d5300d23fc5fafb0fccd18791f30.tar.bz2
LinHES-system: fstrim.cron: trim SSDs weekly
checkXFSfrag.sh: skip defrag on SSDs
Diffstat (limited to 'abs/core/LinHES-system/checkXFSfrag.sh')
-rwxr-xr-xabs/core/LinHES-system/checkXFSfrag.sh22
1 files changed, 15 insertions, 7 deletions
diff --git a/abs/core/LinHES-system/checkXFSfrag.sh b/abs/core/LinHES-system/checkXFSfrag.sh
index 99b833c..74b73c4 100755
--- a/abs/core/LinHES-system/checkXFSfrag.sh
+++ b/abs/core/LinHES-system/checkXFSfrag.sh
@@ -28,24 +28,32 @@
# DO NOT ALTER HEADER FROM THIS LINE UP.
#
e='/bin/echo -e' # Use the echo command, not built-in.
-xfsfsr=/usr/sbin/xfs_fsr # Set variable with the path to xfs_fsr.
-xfsdb=/usr/sbin/xfs_db # Set variable with the path to xfs_db.
+xfsfsr=/usr/bin/xfs_fsr # Set variable with the path to xfs_fsr.
+xfsdb=/usr/bin/xfs_db # Set variable with the path to xfs_db.
pctmax=15 # Set maxiumum frag percent needed for defrag.
# This is zero here for testing purposes only
# a higher number should be used in production.
array=`df -T|grep xfs|cut -f 1 --delim=" "` # Array of all XFS file systems.
for i in ${array[@]};
do
- percentage=`$xfsdb -c frag -r ${i}|cut -f 7 --delim=" "`
- percent2=`$e $percentage|cut -f 1 --delim=.`
- if [ "$percent2" -gt "$pctmax" ]
+ #check that the device is SATA and skip defrag on SSDs
+ device=`echo ${i} | cut -f 3 --delim="/" | sed 's/[0-9]//g'`
+ isSATA=`cat /sys/block/${device}/queue/rotational`
+ if [[ $isSATA -eq 1 ]]
then
- $e "${i} is $percentage fragmented. Running defragment on ${i}."
+ percentage=`$xfsdb -c frag -r ${i}|cut -f 7 --delim=" "`
+ percent2=`$e $percentage|cut -f 1 --delim=.`
+ if [ "$percent2" -gt "$pctmax" ]
+ then
+ $e "${i} is $percentage% fragmented. Running defragment on ${i}."
# Only uncomment one of the following two lines.
#$xfsfsr -v ${i} # Uncomment for verbose defrag.
$xfsfsr ${i} # Uncomment for quiet defrag.
+ else
+ $e "${i} is $percent2% fragmented and is below the fragmentation threshold of $pctmax%. Skipping."
+ fi
else
- $e "${i}\t$percent2 is not above fragmentation threshold of $pctmax."
+ echo "${i} is an SSD. Skipping."
fi
done
exit 0