At work, we want to backup an external disk that’s connected to the Mac machine using rsnapshot. In order to do that, the external drive needs to be mounted, and this happens when a user logs in to the Mac. The problem is that when nobody logs in, the external drive is not mounted and rsnapshot will fail.
The fix should be easy if there is away to mount the external drive without a user logs in. It turns out that on OS X (tested on High Sierra) we can set a flag to have the external drives get mounted when the Mac boots up.
root# diskutil list /dev/disk2 /dev/disk2 (external, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *16.0 TB disk2 1: EFI EFI 209.7 MB disk2s1 2: Apple_HFS Data 16.0 TB disk2s2
$ sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount \ AutomountDisksWithoutUserLogin -bool true