14

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?

13

I just followed the Ubuntu wiki smb guide and it worked for me with Ubuntu 18.04.1

Specifically: 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.

  • 5
    This worked for me I just needed to make sure that cifs-utils was installed for. sudo apt-get install cifs-utils. – anon58192932 Feb 1 at 18:48
  • mount error(95): Operation not supported – crusy Jun 21 at 8:43
  • Same thing for me @crusy – UnsettlingTrend Jul 18 at 22:20
  • 1
    mount error: cifs filesystem not supported by the system on Windows Subsystem for Linux (not strictly speaking Ubuntu) – zypA13510 Sep 22 at 6:52
8

I opened the server i shared and type 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

  • 4
    I kept seeing this error: mount: /mnt/my-mount-name: cannot mount //<server-ip>/path/to/share read-only., and eventually figured out that I had to install cifs-utils first (sudo apt install cifs-utils). After that the mount command worked. – bszom Nov 28 '18 at 9:13
3

If you have installed gvfs-bin you can run:

gvfs-mount smb://username@servername/sharename/

More about gvfs-mount on manpages

Also you can read official wiki Samba/SambaClientGuide

0

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://linuxacademy.com/blog/linux/ubuntu-samba-client-setup-and-persistent-shares/

0

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:

  1. Mount your share once via Nautilus and store the password in the keyring
  2. try gio mount smb://<server_name>/<share_name>, what should work without password in your GNOME session
  3. 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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.