#!/bin/bash # Syntax: filldisk [quiet|verbose] # # This applet fills the disk with files containing a repeating string. # It has two purposes: overwrite any existing deleted files, making undelete # difficult (a _good_ idea for the security-anal), and actually writing to # the majority of the empty blocks on the disk, giving the drives a chance to # exercise their block checking ability. It does not completely fill the # drive; it leaves 1-2M at the end of the regular data space, never touches # the space reserved for root, and doesn't write to space already containing # files. # It currently only fills the partition which contains FILLDIR. # # The idea came from Richard Johnson (root@chaos.analogic.com); thanks Richard! # # This applet is copyright 1998 by William Stearns (wstearns@pobox.com). It # is released under the GNU Public License. Contact the author if you do not # have a copy of this license. #The following is the name of a directory that will hold the temporary fill #files. It must _NOT_ exist. It must be an absolute directory (i.e. starting #with "/". If either of the above conditions are not met, this applet will #not run. FILLDIR="/root/slackspacefilldir" #The following should be a 63 byte string. FILLSTRING="SECURITY SECURITY SECURITY SECURITY " # for ref, "0 1 2 3 4 5 6 " # 63 bytes="123456789012345678901234567890123456789012345678901234567890123" case `echo ${1} | tr A-Z a-z` in help|--help) echo Syntax: ${0} [quiet\|verbose\|help] echo This program fills the available space on the disk containing echo your home directory, then frees the space up again. echo \"quiet\" mode only outputs errors. \"--\" can be used in front echo of any of the options. echo Copyright 1998 William Stearns, released under the GNU public echo license. Contact the author at wstearns@pobox.com if you echo do not have a copy of this. echo exit ;; quiet|--quiet) VERBOSE=NO ;; verbose|--verbose) VERBOSE=YES ;; *) VERBOSE=YES ;; esac cd ~ if [ -e ${FILLDIR} ]; then echo \"${FILLDIR}\" already exists. This program will not continue echo as this directory of file may hold something you wish to keep. echo if you wish to continue, please remove it by hand and rerun echo ${0} ${1} . exit fi if [ "`echo ${1} | cut -b 1`" != "/" ]; then echo \"${FILLDIR}\" does not start with a \"/\". ${0} needs an echo absolute path for its temporary directory. Please edit echo ${0} and enter a different directory name in the FILLDIR line, echo and rerun ${0} ${1} . exit fi if [ ${VERBOSE} = "YES" ]; then echo Creating fill directory. fi mkdir ${FILLDIR} cd ${FILLDIR} if [ ${VERBOSE} = "YES" ]; then echo creating base 1 megabyte file fi COUNT=0 rm -f 1MEG touch 1MEG while [ ${COUNT} -lt 1024 ]; do echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG echo "${FILLSTRING}" >>1MEG COUNT=$[${COUNT}+1] done if [ ${VERBOSE} = "YES" ]; then echo filling drive fi COUNT=2 while [ `df ~/${FILLDIR} | grep -v '^Filesystem' | awk '{print $4}'` -gt 2048 ]; do cp 1MEG 1MEG.${COUNT} COUNT=$[${COUNT}+1] done if [ ${VERBOSE} = "YES" ]; then echo $[${COUNT}-1] 1-megabyte files were written. df fi if [ ${VERBOSE} = "YES" ]; then echo removing files fi cd .. rm -f ${FILLDIR}/* rmdir ${FILLDIR} if [ ${VERBOSE} = "YES" ]; then echo done df fi