i’m using macos bigsur.
I read couple of method of mounting network drive :
commmand line : mount_smbfs //user@server/folder /Users/me/localfolder.
The problem with this one is the mount point will be gone after restarting (not permanent). If i have to run the script at login , it will ask password on every login. I don’t want to put/expose my password on the script like //user:pass@server/folder
Any solution ?
add login items (via system preferences/user/login items).
The problem with this method is that it will mount it automatically on /Volumes/ then i have to add another script to make symlink from this /Volumes/xxx to my /Users/me/localfolder. I prefer to mount directly to home directory.
Any other method ?
EDIT , for more details i add this real scenario :
I’m doing a project with a team (every user use their own workstation/laptop). The ‘project root’ or ‘working folder’ can be in any folder as long as it’s inside the home dir, for example :
/Users/andi/Desktop/__rootfolder__ /Users/John/Documents/projects/__rootfolder__ /Users/Sam/Projects/__rootfolder__ or anywhere else as long as inside /Users/<username>/
Now to be able to pass project to each other and not getting broken link. I setup a ‘virtual root folder’ or symlink which are the same for all users. So every user than has to link their whatever_user_root to /Volumes/__rootfoler__ . For example :
sudo ln -s /Users/andi/Desktop/__rootfolder__ /Volumes/
Now iside the app we use, the working folder is /Volumes/__rotfolder__ which is the same for all user so the app doesn’t know and doesn’t care about /Users/blabla… . So when we send project to other user, the symlink will sort it out for you.
Additionally, there’s an asset folder (contains library, reference etc) which will be shared to all user located on server -> //192.168.1.10/assets. This will be mounted inside rootfolder of each user.
For example it will appear in :
/Users/andi/Desktop/__rootfolder__/assets /Users/John/Documents/projects/__rootfolder__/assets etc
So i do :
mount_smbfs //firstname.lastname@example.org/assets /Users/andi/Desktop/__rootfolder__/assets
inside the virtual folder it will looks : /Volumes/__rootfolder__/assets <– this will be the same for all user regardless where their working folder are.
This is why i prefer mount_smbfs to mount ‘assets’ directly to user folder. Because when using login items, i have to mount to /volumes/ then do symlink back to user dir.
to recap :
- create user working directory or root folder inside each user folder
- make symlink in /Volumes/rootfolder to point to user_rootfolder
- mount //server/assets to /Volumes/assets
- make symlink /Volumes/assets to user_rootfolder/assets
- Any user works will be contained inside user_rootfolder or /Volumes/rootfolder