MacOS Catalina, 10.15.6
foo.dmg, I want to be able to attach it so that its contents will be visible in the Finder application under the
Locations section with an arbitrary name,
When I attach/mount it with the command
$ hdiutil attach foo.dmg
It's being mounted by default under
/Volumes/foo and is visible in MacOS Finder application under the
Locations section as
foo. I don't care what is the directory name (on disk) it's being mounted under in the
/Volumes but I care about the name of the volume visible in the Finder under the
Is it possible to do (programmatically) either
- attach the
foo.dmgunder a different name (that will be visible in the Finder's
- rename the volume once it has been mounted with the default name.
- modify the
foo.dmgfile to amend its volume name to be used when mounting (however my understanding is that the volume name is baked into the
.dmgfile at the creation time and I have no control of it)
$ diskutil list
I can see the mounted disk image:
/dev/disk2 (disk image): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme +494.4 MB disk2 1: Apple_HFS foo 494.4 MB disk2s1
$ diskutil rename /Volumes/foo "/Volumes/bar"
/Volumes/bar does not appear to be a valid volume name for its file system because of the naming limitations (having a
/ in the name)
$ diskutil rename /Volumes/foo "bar"
fails because one cannot write under the root (
Failed to rename volume: Read-only file system (49182).