MountSharesLocally

Guillaume Boudreau edited this page Aug 2, 2016 · 20 revisions

Mounting Greyhole shares locally

Mounting your Samba shares locally is useful when you are using Greyhole, and want to write or in any way work with those files locally. Greyhole data should only be accessed through shares, so mounting those shares locally is an easy way to work with Greyhole data safely.

  1. This script needs /sbin/mount.cifs, so make sure to install cifs-utils or similar, as needed, using your package manager (yum or apt-get).

  2. Install the following init script in /etc/init.d/mount_shares_locally:
    Ubuntu/Debian:
    sudo curl -Lo /etc/init.d/mount_shares_locally https://gist.github.com/gboudreau/1099419/raw
    or Fedora/CentOS:
    sudo curl -Lo /etc/init.d/mount_shares_locally https://gist.github.com/gboudreau/1876068/raw

  3. Make the init script executable, and install it:

    sudo chmod +x /etc/init.d/mount_shares_locally
    sudo update-rc.d mount_shares_locally defaults
    if [ -f /sbin/chkconfig ]; then sudo chkconfig --add mount_shares_locally; fi
    

    Note: If update-rc.d complains about the samba dependency not existing, edit /etc/init.d/mount_shares_locally and change samba to smbd (or smb) in the lines that start with Required-Start and Required-Stop.

  4. Edit /etc/init.d/mount_shares_locally, and replace your_username with the user you'd like to mount the shares.

  5. Create a /home/your_username/.smb_credentials file, with the following content:

    username=your_username
    password=your_password
    domain=HOME
    
  6. Try mounting the shares using: sudo /etc/init.d/mount_shares_locally start

You will find the mounted shares in /mnt/samba/*

Troubleshooting

Unable to mount or other error

The service you installed is automatically going to run on system start up. Sometimes, however, problems can cause the mount to fail silently, with the mounted directories present where they are supposed to be, but it is not actually mounted any more, and you are unable to make any changes to them.

This is mostly caused when the main shares are changed in samba. The service then tries to mount the shares as they were before they were changed, with bad results.

The solution is simply to make sure that the service is stopped (sudo service mount_shares_locally stop or similar), and then to delete the /mnt/samba directory and all it's contents (sudo rmdir /mnt/samba/*). When the service is restarted, everything will mount normally without any issues.