You need to use GNU parted utility - a partition manipulation program. It is perfect tool and works from a shell script. Here is a sample shell script. Make changes as per your setup and test script in a dummy environment.
Code:
#!/bin/sh
PART=$1
if [ $# -eq 0 ]
then
echo "$0 partition-name
echo "$0 /dev/sda1"
exit 1
fi
echo "* Creating partition."
parted -s -- $PART mkpart primary ext3 0 -1
echo "* Formatting the partition."
mke2fs -j -m 0 -O dir_index $PART
Read parted and mke2fs man pages.
HTH