You can use a shell script combined with launchd
to automate the entire process, including creating the mount point (if necessary) and running the mount command. This approach is flexible and avoids relying on /etc/fstab
, which macOS doesn't fully support in all cases.
-
Open a text editor to create the script:
sudo nano /usr/local/bin/mount_europa.sh
-
Add the following script:
#!/bin/bash # Mount point MOUNT_POINT="/Volumes/Europa" NFS_SERVER="10.0.0.4:/volume1/Europa" # Check if the mount point exists; create it if not if [ ! -d "$MOUNT_POINT" ]; then mkdir -p "$MOUNT_POINT" fi # Check if already mounted; if not, mount the NFS share if ! mount | grep -q "$MOUNT_POINT"; then mount -t nfs -o rw,noowners,nolock,hard,intr,proto=tcp,rsize=32768,wsize=32768,nfsvers=3 "$NFS_SERVER" "$MOUNT_POINT" fi
-
Save and exit (
CTRL + O
, thenCTRL + X
). -
Make the script executable:
sudo chmod +x /usr/local/bin/mount_europa.sh
-
Create the
launchd
plist file:sudo nano /Library/LaunchDaemons/com.nickgreenway.mount_europa.plist
-
Add the following content to the plist file:
<?xml version="1.0" encoding="UTF-8"?> <plist version="1.0"> <dict> <key>Label</key> <string>com.nickgreenway.mount_europa</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/mount_europa.sh</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <false/> </dict> </plist>
-
Save and exit (
CTRL + O
, thenCTRL + X
). -
Set the correct permissions for the plist:
sudo chmod 644 /Library/LaunchDaemons/com.nickgreenway.mount_europa.plist
-
Load the
launchd
job:sudo launchctl load /Library/LaunchDaemons/com.nickgreenway.mount_europa.plist
-
Unmount the share if it's already mounted:
sudo umount /Volumes/Europa
-
Trigger the
launchd
job manually:sudo launchctl start com.nickgreenway.mount_europa
-
Verify the mount:
mount | grep Europa
Reboot your Mac and confirm that the NFS share mounts automatically:
sudo reboot
After the system starts, check if the share is mounted:
mount | grep Europa
This method ensures the NFS share is mounted at startup without manual intervention. Let me know if you need any further help!