I am using a mac mini with my home directory on an external ssd. This SSD is encrypted with FileVault and this prevented me from logging in since the disk would not be mounted at login time.
This is how I solved this problem:
- Determine you external disks UUID
ivar@minimac log % diskutil apfs list
APFS Containers (4 found)
|
+-- Container disk3 A4C78520-6C44-4369-B6D3-3BBEF8809024
| ====================================================
| APFS Container Reference: disk3
| Size (Capacity Ceiling): 494384795648 B (494.4 GB)
| Capacity In Use By Volumes: 116917420032 B (116.9 GB) (23.6% used)
| Capacity Not Allocated: 377467375616 B (377.5 GB) (76.4% free)
| |
| +-< Physical Store disk0s2 B6EC8D3A-80A2-4D51-B243-EC9531ACD609
| | -----------------------------------------------------------
| | APFS Physical Store Disk: disk0s2
| | Size: 494384795648 B (494.4 GB)
| |
| +-> Volume disk3s1 000207E7-AA2F-4570-ADD6-08C03AEABFB3
| | ---------------------------------------------------
| | APFS Volume Disk (Role): disk3s1 (System)
| | Name: Macintosh HD (Case-insensitive)
| | Mount Point: Not Mounted
| | Capacity Consumed: 11200786432 B (11.2 GB)
| | Sealed: Yes
| | FileVault: No (Encrypted at rest)
| | |
| | Snapshot: C4274A37-C0E5-4082-BE2E-8C9DC278EB08
| | Snapshot Disk: disk3s1s1
| | Snapshot Mount Point: /
| | Snapshot Sealed: Yes
| |
| +-> Volume disk3s2 950C6069-EF3D-4FB7-BF96-7FF71F810152
| | ---------------------------------------------------
| | APFS Volume Disk (Role): disk3s2 (Preboot)
| | Name: Preboot (Case-insensitive)
| | Mount Point: /System/Volumes/Preboot
| | Capacity Consumed: 6923579392 B (6.9 GB)
| | Sealed: No
| | FileVault: No
| |
| +-> Volume disk3s3 0196D09E-CA05-4BB4-A628-02DD398E3BE6
| | ---------------------------------------------------
| | APFS Volume Disk (Role): disk3s3 (Recovery)
| | Name: Recovery (Case-insensitive)
| | Mount Point: /Volumes/Recovery
| | Capacity Consumed: 1018593280 B (1.0 GB)
| | Sealed: No
| | FileVault: No
| |
| +-> Volume disk3s5 30F7C984-32CC-4C00-B212-7A8A0BD6B50D
| | ---------------------------------------------------
| | APFS Volume Disk (Role): disk3s5 (Data)
| | Name: Data (Case-insensitive)
| | Mount Point: /System/Volumes/Data
| | Capacity Consumed: 95464325120 B (95.5 GB)
| | Sealed: No
| | FileVault: No (Encrypted at rest)
| |
| +-> Volume disk3s6 257206F1-B5DE-478A-91C2-003D522BEBD9
| ---------------------------------------------------
| APFS Volume Disk (Role): disk3s6 (VM)
| Name: VM (Case-insensitive)
| Mount Point: /System/Volumes/VM
| Capacity Consumed: 2147504128 B (2.1 GB)
| Sealed: No
| FileVault: No
|
+-- Container disk5 F65666AB-77A0-44CA-9573-B6377ECFDE76
====================================================
APFS Container Reference: disk5
Size (Capacity Ceiling): 4000577273856 B (4.0 TB)
Capacity In Use By Volumes: 633471152128 B (633.5 GB) (15.8% used)
Capacity Not Allocated: 3367106121728 B (3.4 TB) (84.2% free)
|
+-< Physical Store disk4s2 E46170CF-E864-4262-A383-CE6A07DDA84F
| -----------------------------------------------------------
| APFS Physical Store Disk: disk4s2
| Size: 4000577273856 B (4.0 TB)
|
+-> Volume disk5s1 D97312E1-CD94-478E-AF8F-50CA0E0FB1A9
---------------------------------------------------
APFS Volume Disk (Role): disk5s1 (No specific role)
Name: External (Case-insensitive)
Mount Point: /Volumes/External
Capacity Consumed: 632985948160 B (633.0 GB)
Sealed: No
FileVault: Yes (Unlocked)
The uuid for my external disk is in bold above. Your UUID will not be the same. Write it down. You will need it for the automount script below.
Then type sudo nano /Library/Scripts/mountDisk.sh and paste in the following script taking care of changing the password for the encrypter disk to your password and the UUID to the UUID of your disk.
#!/bin/bash
# Replace with your volume's UUID
VOLUME_UUID="D97312E1-CD94-478E-AF8F-50CA0E0FB1A9"
# Function to mount the disk
mountdisk() {
# Wait for the volume to come online
while :; do
echo "Looking for disk..."
# Check if the volume with the specified UUID exists
diskutil apfs list | grep "$VOLUME_UUID" > /dev/null
# If the volume is found, break the loop
if [ $? -eq 0 ]; then
echo "Volume found."
break
fi
# If not found, wait for 1 second before retrying
echo "Volume not found at $(date). Retrying in 1 second..."
sleep 1
done
# Unlock and mount the encrypted disk
echo "Unlocking and mounting the volume..."
diskutil apfs unlockVolume "$VOLUME_UUID" -passphrase "YourPasswordHere!"
}
# Main script logic
while :; do
# Start by waiting for and mounting the external drive
mountdisk
# Monitor the volume to ensure it remains mounted
while :; do
sleep 1
# Get the "Mounted" status of the volume
MOUNTED_STATUS=$(diskutil info "$VOLUME_UUID" | grep "Mounted" | awk '{print $2}')
# If the volume is still mounted, continue monitoring
if [[ "$MOUNTED_STATUS" == "Yes" ]]; then
continue
else
# If the volume becomes unmounted, break the loop and attempt to remount
echo "Disk has become unmounted. Attempting to remount..."
break
fi
done
done
Once this script is saved we need to create the launchagent configuration file. run the command:
sudo nano /Library/LaunchDaemons/com.example/mountDisk.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example/mountDisk</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Library/Scripts/mountDisk.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/mountDisk.log</string>
<key>StandardErrorPath</key>
<string>/var/log/mountDisk.log</string>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
At this point if the disk is mounted log in as a user with a home directory on the internal drive that has admin rights. Make sure to log out as yourself first. This should unmount the external disk. Then run the following command as the internal admin user:
chmod ug=rx,o= /Library/Scripts/mountDisk.sh
sudo /Library/Scripts/mountDisk.sh
This should run the script and it should say that it found the disk and mount it. Then it will just sit there waiting for the disk to be unmounted. When that happens it will remount it and wait again until its unmounted. This will repeat endlessly. You can use control+c to interrupt the script.
Once it works fine then it is time to add the service to the system so the disk gets mounted automatically at boot. Use this command to do this:
sudo launchctl load /Library/LaunchDaemons/com.example/mountDisk.plist
Then reboot the host. Once it gets back to the login screen you should now be able to log in as the user with its home directory on the external drive.
This also works if you enable autologin.
Have fun with this and spend the $$ yuou save on not buying apples expensive storage upgrades wisely.