Skip to content
Guillaume Boudreau edited this page Sep 12, 2020 · 24 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).

  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
    # If your system uses update-rc.d (Ubuntu, Debian), execute this:
    sudo update-rc.d mount_shares_locally defaults
    # If your system uses chkconfig instead (Fedora, CentOS), execute this:
    sudo chkconfig --add mount_shares_locally
    

    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 Samba user you'd like to use 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.