Auto-mount of the contained disk-image, when the external disk is mounted I have one external SSD drive that automatically mounts a partition Backup.
Inside Backup there is a sparse-bundle disk image called TimeMachine.

Backup is not mounted to /Volume but to a specific folder (synced with a cloud service), via /etc/fstab:

UUID=4E5D0103-741G-46DA-A79E-F923E5C951D1 /Users/myuser/Cloud\040Folder/Backup apfs rw 0 2


How can I trigger the automatic mount of TimeMachine, when detecting that Backup has been mounted?



Something like hdiutil attach /Users/myuser/Cloud\040Folder/Backup/TimeMachine.sparsebundle, being run when detecting that /Users/myuser/Cloud\040Folder/Backup is present.

Maybe the /etc/auto_master file might help? (I've never used it before)
You can create a launchd LaunchDaemon definition with the key “StartOnMount” set to true. This will allow you to have your own script run whenever something is mounted.

Your own script should then just check if “Backup” is mounted without “TimeMachine” being mounted - and if so, mount “TimeMachine”.

You can use the “mount” command to get information on the currently mounted file systems.