I mounted a shared server on my local network using the GUI connect to server and the address I entered was
smb://myServer/myFolder. Then i tried to add the shared folder to the
/mnt directory so I can access to it through my IDE but I failed even though I tried unmount the server and use the CLI with the command
gio mount smb://myServer/myFolder**.
Anyone had this problem before?
Here is Solutions:
I opened the server i shared and typed ifconfig to get the ip adress. Then I typed this command to list of shares
smbclient -L //myServerIpAdress
Then to mount it I typed these 2 commands: first to create a folder under the /mnt and then to do the mount
sudo mkdir /mnt/myFolder sudo mount -t cifs -o username=serverUserName //myServerIpAdress/sharename /mnt/myFolder/
Then enter the server’s password when asked and your mount is done under /mnt/myFolder
I just followed the Ubuntu wiki smb guide and it worked for me with Ubuntu 18.04.1
I first creating the directory for the mount
sudo mkdir /media/NAS
I added the following line to my fstab
//192.168.1.209/public /media/NAS cifs guest,uid=1000,iocharset=utf8 0 0
and then ran
sudo mount -a
From then my NAS drive was mounted. I have rebooted my machine several times and confirmed that it now mounted and start up for me. For what its worth I’m using an Ethernet connection so it could be configured and up and running quicker than a wi-fi connection would be.
Note, that you might better add the SMB protocol version (e.g.vers=1.0) to the mount options. The mount.cifs states to use vers=1.0 as default, but it doesn’t and you are trapped with a “host down” error when trying to mount to an older NAS.
The above solution then reads
sudo mount -t cifs -o username=serverUserName,vers=1.0 //myServerIpAdress/sharename /mnt/myFolder/
See this solution for details.
If you have installed
gvfs-bin you can run:
gvfs-mount smb://[email protected]/sharename/
More about gvfs-mount on manpages
Also you can read official wiki Samba/SambaClientGuide
I always wanted to use stored passwords from my keyring for accessing SMB shares in scripts (backups) on my laptop. My aim was not to expose the passwords in files and use anacron to run the backups. After some testing I came up with this:
- Mount your share once via Nautilus and store the password in the keyring
gio mount smb://<server_name>/<share_name>, what should work without password in your GNOME session
- Use the following code in backup scripts:
Example tested on Ubuntu 19.04:
# set the dbus address DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus" # export dbus address to get access to user space keyring export DBUS_SESSION_BUS_ADDRESS # use new gnome user space mount tool (gvfs-mount is deprecated) gio mount smb://<server_name>/<share_name> #sync from gvfs created mount point to home dir rsync -rav /var/run/user/$(id -u)/gvfs/smb-share\:server\=<server_name>\,share\=<share_name>/<folder>/ ~/<sync_dest>/
When running the script via anacron from /etc/cron.daily you need to use the user that has access to the keyring, e.g.:
su -c /home/user/scripts/rsync_sript.sh user
On Ubuntu 18.04, the GNOME Virtual Filesystem mounted from Nautilus can be found in
/run/user/1000/gvfs. For example, one can
cd into a Samba share with
The answer of @Phoenix87 helped me a lot to get access to a samba-drive that is already mounted via Nautilus, but not shown in VSCode. So I put a link under
/home/user/.config/gtk-3.0/bookmarks and now can open a workspace via smb in VSCode too.
SMBv1 and shares without password protection get the job done quick and easy. But they are definitely a huge security issues (e.g. WannaCry, etc).
Recommend SMBv3 shares with password protection of shares. Using secured credential files in fstab is probably wise too. Linux client side is very similar to above. See procedures at https://acloudguru.com/blog/engineering/ubuntu-samba-client-setup-and-persistent-shares
Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂