This is how I disable auto mounting of APFS volumes on macOS Catalina.
For macOS volumes, both Macintosh HD - Data and Macintosh HD type volumes need to be referenced in /etc/fstab.
Find volume(s) using diskutil list and set VOLUME_PATH accordingly.
# Disable auto mounting of "macOS - Data" volume
VOLUME_PATH="/Volumes/macOS - Data"
VOLUME_UUID=`diskutil info "$VOLUME_PATH" | awk '/Volume UUID:/ { print $3 }'`
cat << EOF | sudo tee -a /etc/fstab
UUID=$VOLUME_UUID none apfs rw,noauto
EOF
Disable auto mounting of "macOS" volume
VOLUME_PATH="/Volumes/macOS"
VOLUME_UUID=diskutil info "$VOLUME_PATH" | awk '/Volume UUID:/ { print $3 }'
cat << EOF | sudo tee -a /etc/fstab
UUID=$VOLUME_UUID none apfs rw,noauto
EOF
Here is what is going when running above commands:
Set VOLUME_PATH variable to /Volumes/macOS - Data
VOLUME_PATH="/Volumes/macOS - Data"
Set VOLUME_UUID variable to volume UUID of /Volumes/macOS - Data volume
Running diskutil info "$VOLUME_PATH" outputs volume details of /Volumes/macOS - Data (which includes its UUID).
Piping (|) these details to awk '/Volume UUID:/ { print $3 }' extracts the UUID.
VOLUME_UUID=`diskutil info "$VOLUME_PATH" | awk '/Volume UUID:/ { print $3 }'`
Append UUID=$VOLUME_UUID none apfs rw,noauto to /etc/fstab and output to console (see tee)
cat << EOF | sudo tee -a /etc/fstab
UUID=$VOLUME_UUID none apfs rw,noauto
EOF
diskutil unmount force disk1s2Also, if you choose a filesystem that spotlight won't index or set that drive to be excluded in Spotlight preferences, you can reduce that delay and overhead with a quick setting change. – bmike Feb 12 '14 at 18:01Spotlight, anti-viruses and attacks. – dan Jan 29 '15 at 10:03