It sounds like your disk image is in a non-writable format.
If this is the case, try converting your disk image to a writable one, using "ImagesImages > Convert"Convert in Disk Utility's menu bar, and selecting "read/write" in the ensuing save-dialog'sSave dialog's popup menu for format. Then, you should be able to rename the mounted volume to bar
using the Finder or the diskutil rename
command.
After your volume is renamed, you can convert the disk image back to the format you currently have it in.
Another alternative would potentially be to use Disk Utility to create a new read-only disk image from scratch (Using FileFile > New ImageNew Image > Image from Folder…Image from Folder…) from the files in the mounted volume at /Volumes/foo
. You would choose the name bar.dmg
, which would cause Disk Utility to name the inner mountable volume bar
. Then, you would rename your disk image file to foo.dmg
.
Both of these paths would get you to your stated goal of having a file named foo.dmg
mount a volume named bar
with the files currently inside your volume named foo
.
I hope one of them works for you!