#!/bin/bash -x
#
# ---
# zerofill.sh
# ---
#
# Poor man's zerofill to fill up unusued space with zeroes
# for better compaction of virtual hard-disk.
#
# For my simple solaris 11 openindiana installation, this zeroes out empty
# disk space on /tmp/ (user partitions are TBD)
# Zeroing out other partitions not supported yet
#
# This script just creates a big file with zeroes and deletes it. To monitor
# progress you can you something like
# while [ 1 ]; do date; ls -lh /tmp/zero* ; df -h; sleep 10; done
#
# Supratim Sanyal - http://mcaf.ee/sdlg9f
# License: GNU AGPLv3 (http://tuklusan.decsystem.org/agpl-3.0-standalone.html)
# ---
#

if cd /tmp/ ; then
    cat /dev/zero > zero.delete-me
    sync
    rm -f zero.delete-me
    sync
else
    echo "FAIL - no directory to create zero file in"
fi
exit