Skip to content

Instantly share code, notes, and snippets.

@graysky2
Last active April 8, 2018 13:35
Show Gist options
  • Save graysky2/c97f47b8f1a0f5d8ae3d664780ddf20d to your computer and use it in GitHub Desktop.
Save graysky2/c97f47b8f1a0f5d8ae3d664780ddf20d to your computer and use it in GitHub Desktop.
#!/bin/bash
## run as root
## NFS is your NFS mount
NFS=/scratch
if ! mountpoint -q "$NFS"; then
echo "$NFS should be a mounted NFS partition"
exit 1
fi
for i in 1 2 3 4; do
IMG="$NFS/image.$i"
MP="$NFS/mp"
truncate -s 8G "$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 $i"
#dd if=/dev/urandom of="$MP/rnd.$i" bs=4M count=1000 status=progress
dd if=/dev/zero of="$MP/rnd.$i" bs=4M count=1000 status=progress
ls -l "$MP"
echo "Round $i done"
umount "$MP"
rmdir "$MP"
rm -f "$IMG"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment