Write a disk full with files with random or zero data

I wanted to test a hard-drive that halted when its internal temperature raised above its safety level. hdparm is one option but the script below creates different files with a certain given size.

#!/bin/bash
COUNTER=0
while [ true ]; do
dd if=/dev/zero of=file$COUNTER bs=$1 count=1024
let COUNTER=COUNTER+1
done

You can replace /dev/zero with /dev/random if you want random data. Call the script with one argument, the file size.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.