rm imgfile && rmdir imgdir  # uncomment for easier testing and damage, OOM

set -e  # abort on error
test ! -e imgdir  # error when path exists
test ! -e imgfile

# a BUG: dd fails to open with "Invalid Argument" error when of=/imgfile is used instead
dd if=/dev/zero of=imgfile bs=32M count=1  # create big enough empty file

read -p "Press Return to continue"  # with/without this, it either works or mkfs or mount fails:
# DiskDevicejobQueue::Execute(): executing job failed: Bad data
# mkfs: Initialization of "Test" failed: Bad data
# mount: General system error
mkfs -q -t fat imgfile Test  # initialize it as FAT32 filesystem (not partitioned)
mkdir imgdir  # create empty folder

read -p "Press Return to mount now"
mount imgfile imgdir  # mount our new filesystem

read -p "Press Return to start cleanup now"
unmount imgdir  # unmount
rmdir imgdir  # delete what we created
rm imgfile
