Your script seems like a viable option to me. I've seen far more convoluted workarounds to issues in Linux.
Another alternative is a systemd automount which fulfills the or at least mounting automatically upon access requirement. Simple enough to implement and revert back if it's not exactly what you want.
 Unmount the share if it is already mounted:
Software is installed in various standard places, including '/bin,/usr/bin' and /opt/... This i as designed. You can't easily change this, and since theese packages don't take much space it is not a problem.
You configure Samba to share the directories (path's) you want. So if your 2 TB disks is mounted at /media/disk1 and /media/disk2 you will have to ...
There's two places where share definitions are held depending on how you created the share:
 In /etc/samba/smb.conf itself. Just edit that file and remove the share definition. THen restart smbd: sudo service smbd restart
 In /var/lib/samba/usershares. If you did it this way there is a file for every share that you created from your file manager. ...
I tried using file_mode and dir_mode as described here
The only problem with the link is a missing option since this is Linux to Linux.
If 770 is what you desire on the client give this a shot:
//myserver.local.lan/data /mnt/data cifs username=dataadmin,password=notarealpassword,iocharset=utf8,dir_mode=0770,file_mode=0770,nounix 0 ...
Samba conf file (/etc/samba/smb.conf)
When I use conf like this, everybody can access it:
path = /home/test_2
public = yes
Force group = nogroup
writeable = yes
force user = nobody
When I add allow hosts =:
allow hosts = 192.168.0.10, 192.168.0.11, 192.168.0.13, 192.168.0.25
path = /home/test_2
public = yes
Force group = nogroup
In comments, I described the configuration I used, which allowed the OP to determine a solution.
I made everything owned by a user1, let people sign on w/own userid
and then force user user1 in the config file. Who owns client side
mount points? For me forcing was only way it worked, but I am no
The OP stated that based on this comment, ...
//192.168.5.167/H /mnt/ssd ssd credentials=/root/.smbreds 0 0
Did you mean:
//192.168.5.167/H /mnt/ssd cifs credentials=/root/.smbreds 0 0
Unmount the share:
sudo umount /mnt/ssd
Edit fstab and add two more options: noauto and x-systemd.automount:
//192.168.5.167/H /mnt/ssd cifs credentials=/root/.smbreds,noauto,x-systemd.automount 0 0
Then do the ...
If you read man fstab you will see the next options you could try in your case:
noauto do not mount when "mount -a" is given (e.g., at
nofail do not report errors for this device if it does
The next step could be a script in cron that checks host availability and connects your windows share ...
You should consider user autofs instead of fstab. AutoFS will mount the share on demand.
Install the requirements with
sudo apt install autofs smbclient cifs-utils
Add the following line into /etc/auto.smb.
sudo /cifs /etc/auto.smb --timeout=300
Of course create the folder
sudo mkdir /cifs
Restart the service
sudo systemctl restart autofs
This sounds like a wonderful use case for samba! Here's an official turorial from the Ubuntu site. Additionally, this forum post may be helpful(I'm not too sure what LMS is myself, but from your description, it seems to stand for logitech media server)
The system will block everyone except aldimere from getting to anything past /media/aldimere.
You can either mount the partition somewhere else like /media/ef018901-2b4c-41f4-ba56-f17a751c0a3a
Or you can edit /etc/samba/smb.conf and right under the workgroup = WORKGROUP line add this line:
force user = aldimere
Then restart smbd:
sudo service smbd ...
Fix it with this:
sudo chown -R _apt:root /var/lib/apt/lists
The lists directory itself, not just its contents, needs to have owner _apt. (i.e. Here is one important file branch where default root ownership fails!)
I may have developed this issue when removing lists, and then re-making it with sudo mkdir lists; apt update, as advised elsewhere.
To get some insight into what may be occurring, try installing smbclient:
sudo apt update
sudo apt install smbclient
Then try connecting to see if you receive any error messages which can give some insight into this issue (replace the items in the brackets with the appropriate details):
smbclient //<IP or hostname>/<share> -U <connection ...
The "force create mode" and "force directory mode" parameters force Samba to create new files and folders with the set permissions.
And you have to make sure that these folders are owned by the correct user.
Once you have created these folders they might already have the wrong permissions.
Here is the official samba doc.
I entered the username/password of my Ubuntu user
Unlike Windows where there is just the one user in Linux there are two. One for local logins and the other for samba.
You need to add the local user ( mark for example ) to the samba password database:
sudo smbpasswd -a mark
ajgringo619 corrected your sytax. The only thing remaining is to take possession of the mounted share with a uid=user:
sudo mount -t cifs -o rw,user=user,uid=user //ServerIP/share /home/user/documents/share
The user in user=user is the user name you pass to the server as credentials. The user in uid=user is the user name on the client that is mounting the ...
Can you read and see the files on the host system?
Is there any unusual file name?
Can you open all these files on the host system?
Can you mount the samba share manually from command line?
Increase the log level in smb.conf and have a look in the smbd.log, nmbd.log