Gold star for anyone that can figure out how to use the diskutil command to partition a hard drive from within a script, with partitions whose names contain spaces. No, it's not as easy as you think.

diskutil partitiondisk /dev/disk4 2 APM JHFS+ abc 2G JHFS+ 'def ghi' R

works when typed in directly on the command line. I have been unsuccessful at setting a shell variable by any reasonable or unreasonable means to get it to work within a script. diskutil appears to have a (borken) check to verify you provided the correct number of parameters, that does not adhere to any method of escape I can find, and so bails out crying about incorrect parameter count.

I would like this because my service drives require 12 partitions, and having to go into disk utility to do it manually when I have to repartition a bunch of them at once is a PAIN. At the moment the best solution I have come up with is to have the script build the command and display it to terminal and say "ok now cut and paste this...." but I don't call that a proper solution.

Right now I have to paste this, which is messy to edit:

diskutil partitionDisk /dev/disk4 12 APM JHFS+ "Service Lion" 17G JHFS+ "Service Snow" 15G JHFS+ "Service Leopard" 23G JHFS+ "Service Tiger" 12G JHFS+ "Mac OS 10.3.4" 1G JHFS+ "Mac OS 10.3.4 Disc 2" 1G JHFS+ "Mac OS 10.4.6" 4G JHFS+ "Mac OS 10.4.7" 6G JHFS+ "Mac OS 10.5.6" 8G JHFS+ "Mac OS 10.6.3" 9G JHFS+ "Mac OS 10.7.0" 9G JHFS+ Diags R


I work for the Department of Redundancy Department