hdituil detached the image, it would vanish. e.g.,
osascript -e 'tell app "Finder" to set background picture of icon view options of container window of disk "disk_name" to POSIX file "full_path_to_image_file_on_disk_image"'
hdituil detach /Volumes/disk_name
We found that running
syncwouldn’t help, but that if we waited a while (e.g.,
sleep 5), it would usually “take.” Well, Apple replied with the Magic™: The Finder doesn’t commit the changes made to Finder metadata immediately to disk, and whereas if you told the Finder to eject the disk, it would know better, write its metadata and then eject, but for whatever reason
hdiutil detachwould just unmount the disk image out from under the Finder and it wouldn’t necessarily have known to write the metadata first.
Workaround and/or fix: Use the
update diskverb to force the Finder to write out the metadata. e.g.,
osascript -e 'tell app "Finder" to update disk "disk_name"'
That should make sure that background image and icon size/placement settings that you made get committed before the