My notepad

Chris' IT notes…

Skip to content
  • Home
  • Here are my notes…

MAC – Auto mount shares at Login

There are multiple ways to make your mac mounting shares at login.
What I was trying to achieve is mounting Documents, Desktop and all the main data folders shared from my Linux host machine into my MAC VM.

And yes, I’m running MAC OS within a VMWare Virtual Machine from an Ubuntu computer.

Here the way that worked for me 🙂

Create a bash script called mount_all.sh with all your lines and I have stored it into /Users/macuser:

mount_all.sh
Shell
1
2
3
4
5
6
7
8
#!/bin/bash
 
sudo mount -t vmhgfs .host:/Desktop /Users/macuser/Desktop
sudo mount -t vmhgfs .host:/Documents /Users/macuser/Documents
sudo mount -t vmhgfs .host:/Downloads /Users/macuser/Downloads
sudo mount -t vmhgfs .host:/Movies /Users/macuser/Movies
sudo mount -t vmhgfs .host:/Music /Users/macuser/Music
sudo mount -t vmhgfs .host:/Pictures /Users/macuser/Pictures

Than, I have created the following file in /Library/LaunchAgents/ (as root) called com.vmware.launchd.z-custom-mount.plist:

com.vmware.launchd.z-custom-mount.plist
XHTML
1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>com.vmware.custom-mount</string>
   <key>Program</key>
   <string>/Users/macuser/mount_all.sh</string>
   <key>RunAtLoad</key>
   <true/>
</dict>
</plist>

After, I have verified that the syntax was ok with this plutil command:

Shell
1
2
root:/Library/LaunchAgents # plutil com.vmware.launchd.z-custom-mount.plist
com.vmware.launchd.z-custom-mount.plist: OK

Last step is to load the file:

Shell
1
launchctl load com.vmware.launchd.z-custom-mount.plist

DONE!

At your next boot, once login, the script mount_all.sh will be executed 🙂

The nice thing here is that you have the flexibility to add/remove shares simply modifying that script, without really need to change any System configuration.

 

NOTE: I had to add this in visudo

Shell
1
macuser ALL=(ALL) NOPASSWD: /sbin/mount,/sbin/umount

 

This entry was posted in Linux, Mac, Scripting and tagged automation, hack, login, script, vm, VMware on February 4, 2017 by thtieig.

Post navigation

← Linux Firewall notes Super fast creation of large file in Linux →

My notes… organised a bit

  • Cloud (33)
  • Containers (3)
  • Linux (178)
  • Mac (22)
  • Networking (16)
  • Scripting (51)
  • Virtualisation (8)
  • Windows (3)

Tags

  • apache
  • api
  • automation
  • backup
  • bash
  • basic
  • centos
  • centos7
  • cloud
  • command line
  • convert
  • debian
  • innodb
  • linux
  • lvm
  • mac
  • monitoring
  • mysql
  • nagios
  • nc
  • nfs
  • notes
  • openstack
  • php
  • php-fpm
  • rackspace
  • raspberry pi
  • redhat
  • redirect
  • rsync
  • script
  • server
  • shortcut
  • ssh
  • ssl
  • test
  • troubleshooting
  • ubuntu
  • ubuntu 16.04
  • varnish
  • vim
  • vm
  • VMware
  • windows
  • wordpress
Proudly powered by WordPress