-
-
Notifications
You must be signed in to change notification settings - Fork 34
MountSharesLocally
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.
-
This script needs
/sbin/mount.cifs
, so make sure to installcifs-utils
or similar, as needed, using your package manager (yum
orapt
). -
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
-
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 thesamba
dependency not existing, edit/etc/init.d/mount_shares_locally
and changesamba
tosmbd
(orsmb
) in the lines that start withRequired-Start
andRequired-Stop
. -
Edit
/etc/init.d/mount_shares_locally
, and replaceyour_username
with the Samba user you'd like to use to mount the shares. -
Create a
/home/your_username/.smb_credentials
file, with the following content:username=your_username password=your_password domain=HOME
-
Try mounting the shares using:
sudo /etc/init.d/mount_shares_locally start
You will find the mounted shares in /mnt/samba/*
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.