Advertisement
gheja

Untitled

Dec 19th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.92 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# != 1 ]; then
  4.         echo "$0 <target_dir>"
  5.         exit 1
  6. fi
  7.  
  8. if [ ! -e "$1" ]; then
  9.         echo "Target dir does not exist, exiting."
  10.         exit 1
  11. fi
  12.  
  13. target_dir="$1"
  14. temp_dir="/tmp/filetest.$$"
  15.  
  16. mkdir -p $temp_dir
  17.  
  18. cd $temp_dir
  19.  
  20. echo "Temp dir: $temp_dir"
  21. echo "Target dir: $target_dir"
  22. echo ""
  23. echo "Creating temp files..."
  24.  
  25. i=0
  26.  
  27. while [ 1 ]; do
  28.         free_kbytes=`df -k $target_dir | tail -n 1 | awk '{ print $4; }'`
  29.  
  30.         if [ $free_kbytes -lt 200000 ]; then
  31.                 break
  32.         fi
  33.  
  34.         file="temp${i}.tmp"
  35.  
  36.         echo "$file"
  37.  
  38.         dd if=/dev/urandom of=$file bs=1M count=200 2>/dev/null >/dev/null
  39.  
  40.         md5sum $file >> md5sum.txt
  41.  
  42.         mv $file $target_dir
  43.  
  44.         sync
  45.         echo 3 > /proc/sys/vm/drop_caches
  46.  
  47.         i=$((i + 1))
  48. done
  49.  
  50. echo ""
  51. echo "Checking temp files..."
  52.  
  53. cd $target_dir
  54.  
  55. md5sum -c < $temp_dir/md5sum.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement