Hi Leon! I had the same problem as you did. I also found the original article you linked to, but wasnt able to replicate the fdisk partitioning represented there. Yours worked just fine, thank you so much for sharing this information with us.
I added a intermediate step to your step1.sh and step2.sh, which basically partitions the disk as required. Its contents follows below:
# As Ubuntu 16.04 sometimes automatically mounts after step1.sh, this unmount them all before we continue.
mdadm --stop /dev/md*
# now, to the partitioning section
(
# partition /dev/sdd2
echo n
echo p
echo 2
echo 4018176
echo 1953525167
echo t
echo 2
echo fd
# partition /dev/sdd6
echo n
echo 518144
echo 620543
echo t
echo 6
echo 83
# partition /dev/sdd7
echo n
echo 622592
echo 724991
echo t
echo 7
echo fd
# partition /dev/sdd8
echo n
echo 727040
echo 2365439
echo t
echo 8
echo fd
# partition /dev/sdd9
echo n
echo 2367488
echo 4005887
echo t
echo 9
echo fd
# save all changes
echo w
) | fdisk /dev/sdd
# this last part is needed because sometimes fdisk hangs at this batch procedure.
partprobe
Hope this helps other people out there.