Skip to content

Instantly share code, notes, and snippets.

@graysky2
Last active June 11, 2018 19:55
Show Gist options
  • Save graysky2/c6e470ed482074b8978afc4cb8b468b8 to your computer and use it in GitHub Desktop.
Save graysky2/c6e470ed482074b8978afc4cb8b468b8 to your computer and use it in GitHub Desktop.
#!/bin/bash
limit=30
NFS=/scratch
LOG=/home/facade/results.csv
if ! mountpoint -q "$NFS"; then
echo "$NFS should be a mounted NFS partition"
exit 1
fi
calc() {
diff=$(echo "scale=6; $finish - $start" | bc)
simpdiff=$(echo "scale=2; $finish - $start" | bc)
runsleft=$(echo "scale=2; $limit-$x"| bc)
secleft=$(echo "scale=2; $runsleft*$diff"|bc)
minleft=$(echo "scale=2; $runsleft*$diff/60"|bc)
eta=$(date -d "($date) $secleft sec" +%r)
echo " ==> Run $x/$limit took $simpdiff seconds. ETA: $eta or about $minleft min from now."
echo "$diff sec to write $size MB ($x of $limit)" >> "$LOG"
}
#for size in 500 1500; do
for size in 1500; do
x=0
while [[ "$x" -lt "$limit" ]]; do
x=$(( x + 1 ))
IMG="$NFS/image.$x"
MP="$NFS/mp"
truncate -s 2G "$IMG"
mkfs.ext4 -F "$IMG" &>/dev/null
[[ -d "$MP" ]] || mkdir "$MP"
mount -o loop "$IMG" "$MP"
# write out 4G of random data to the mounted image
echo " ==> Writting round $x for $size MB"
RUNDATE=$(date "+%F %T")
start=$(date +%s.%N)
dd if=/dev/zero of="$MP/rnd.$x" bs=1M count=$size status=progress
finish=$(date +%s.%N)
calc
umount "$MP"
rmdir "$MP"
rm -f "$IMG"
done
done
@graysky2
Copy link
Author

graysky2 commented Jun 11, 2018

For me, the larger size triggers the error in less iterations. (commented out line 25)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment