How to access a NAS under Linux?

Get help for specific problems
Posts: 16
Joined: 1 Aug 2017

gcvdberg

I have a PC with Linux Mint 18.3 and I want to use FFS 9.8 to sync parts of my harddisk to a Western Digital NAS (My Book Live). However, in FFS I can't input the target directory for the NAS, I cannot search for a network. But in the Nemo file manager the intended share on the NAS is very well reachable. I can take the intended directory path from the file manager and copy this into the FFS target field, but when I click the Compare button I get an error message that the target directory couldn't be found. Does someone knows a solution?
Posts: 306
Joined: 7 Jan 2018

bgstack15

Do you already have a mountpoint on the filesystem for your NAS? I.e., do you have it mounted so you can access it as "/mnt/NAS1/mydirectory"? Or are you using some other string to connect to in Nemo?
Posts: 16
Joined: 1 Aug 2017

gcvdberg

Thanks for your reaction. I haven't mounted it so far. I just found out that it is possibly a mounting issue. I found the advice to enter a specific command using the Cifs-util Suite. I have to work this out. But when you can help me, you're welcome. I'm no expert in this matter and new to Linux.
Posts: 306
Joined: 7 Jan 2018

bgstack15

I come from the Fedora side of the Linux family, so my debian-fu is weak. On Fedora, you need to install cifs-utils package (dnf install cifs-utils) to be able to mount SMB shares as a regular mount point. To see what is currently mounted, in a terminal enter "mount" just by itself. An SMB share will show up as "//nethost1/networkshare1/subfolder on /mnt/networkshare1 type cifs (rw,...)" or similar. But the UNC pathing is key: the double-slashes at the front.

I just checked my Lubuntu 16.04 system, and the package name is still cifs-utils. So run:
sudo apt-get update && sudo apt-get install cifs-utils
I suspect that FreeFileSync will work best if you mount the network share as a regular filesystem. Some applications are network-aware (like Nemo, with the smb:// protocol) but even that still might depend on the cifs-utils package being present. But once you have that, you can mount the share so it looks like it's just another local directory and then use FreeFileSync that way. I recommend "mount SMB on Linux Mint" in a search engine if you still need to finish that part.
Posts: 16
Joined: 1 Aug 2017

gcvdberg

The CIFS-Utils software is already active. For the Public share of my NAS I did the following:
I made a mount point: /mnt/shares/Public.
Then I mounted the share with the command

sudo mount.cifs //192.168.178.17/Public/ /mnt/shares/Public/

(The IP-address is the one of my NAS).
But this gives a mount error(22): Invalid argument. I fond out that this is a very general error message, it just says something is wrong.

I look further.

I contacted Western Digital, but they are not willing to answer Linux questions.
Posts: 306
Joined: 7 Jan 2018

bgstack15

Can you share the output of:
mount -v -t cifs //192.168.178.17/Public /mnt/shares/Public
Posts: 16
Joined: 1 Aug 2017

gcvdberg

On
mount -v -t cifs //192.168.178.17/Public /mnt/shares/Public
I get the following result:
mount: only root can use "--types" option

On
sudo mount -v -t cifs //192.168.178.17/Public /mnt/shares/Public
I get the following result:
mount.cifs kernel mount options: ip=192.168.178.17,unc=\\192.168.178.17\Public,user=root,pass=********
Unable to find suitable address.

Hope you can do something with it.
Posts: 306
Joined: 7 Jan 2018

bgstack15

This page shows up in a search result: https://askubuntu.com/questions/108462/mount-unable-to-find-suitable-address. I bet some of those options are worth trying. The main one to try: Try using the netbios name as the share name (i.e., //servername/folder1/folder2/...) and include a -o ip=192.168.178.17. Also, you might need to use a valid username from the CIFS share, and not just "root."
sudo mount -v -t cifs -o ip=192.168.178.17,unc=\\192.168.178.17\Public,user=SAMBAUSER //servername/Public/folder1/folder2 /mnt/shares/Public
Posts: 16
Joined: 1 Aug 2017

gcvdberg

Dear bgstack15,
Thanks for your ongoing support!
I need some more time for further investigation
You hear from me.
Posts: 16
Joined: 1 Aug 2017

gcvdberg

I did many attempts with the mount command, such as:
sudo mount -v -t cifs -o ip=192.168.178.17,unc=\\192.168.178.17\Public,user=SAMBAUSER //MyBookLive/Public /mnt/shares/Public
with the following result:
ip address 192.168.178.17 override specified
mount.cifs: bad UNC (\192.168.178.17Public)

I contacted Western Digital again and now they gave me the following info:
The My Book Live (my NAS) has a Linux file system and it has been tested in the Windows and Mac environments up to Windows 7 and Mac OS Mountain Lion. It has not been tested in a Linux environment and we cannot recommend or assure its compatibility. The Product Overview lists this information: http://products.wdc.com/library/AAG/ENG/4178-705202.pdf

The following protocols are suppored: CIFS/SMB, NFS, FTP, AFP, and they are the possible ones used to access your device. Please find instructions on how to map the device on Windows in case it can be used as an example: https://support.wdc.com/knowledgebase/answer.aspx?ID=2676&h=2&lang=en

In order to map it, it is necessary to use one of the protocols and include the path to the device, I suppose its IP Address. I wouldn't know which commands were needed.
When I approach my NAS in the network via the Nemo file manager, then the path is afp://MyBookLive.local/
From here I can approach the different shares. Eg. for share Public, this is afp://MyBookLive.local/Public/
However I cannot use this in FFS

I think I have to leave this for a while. Maybe later I have (or a reader has) a good idea!
Posts: 306
Joined: 7 Jan 2018

bgstack15

In bash, you should use single quotes to protect the strings that contain slash \ symbols. If you don't, the slashes will be interpreted as escape characters, so they will "escape" the following character.
Try this:
sudo mount -v -t cifs -o 'ip=192.168.178.17,unc=\\192.168.178.17\Public,user=SAMBAUSER' //MyBookLive/Public /mnt/shares/Public
Without the single quotes, the \\ will be interpreted as a single \, which would definitely not be correct. You're getting closer! Don't put this project on hold just yet.
Posts: 16
Joined: 1 Aug 2017

gcvdberg

See the result
~ $ sudo mount -v -t cifs -o 'ip=192.168.178.17,unc=\\192.168.178.17\Public,user=SAMBAUSER' //MyBookLive/Public /mnt/shares/Public
ip address 192.168.178.17 override specified
Password for SAMBAUSER@//MyBookLive/Public:  ****************
mount.cifs kernel mount options: ip=192.168.178.17,unc=\\MyBookLive8.17\Public,unc=\\192.168.178.17\Public,user=SAMBAUSER,pass=********
mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I did it with all the passwords I have available. Can you tell me what this SAMBAUSER is?
Thanks for your encouraging support. Yes I think I'm close, but still not close enough!
Posts: 306
Joined: 7 Jan 2018

bgstack15

Oh, sorry. The "SAMBAUSER" was supposed to be replaced with whatever user account that has access to the network share. So it could be "admin," or "gcvdberg," or something else. I personally use "public" with one of my generic passwords from the past for all my public (public within my network) network shares.
If you have time, you could read the man page for mount.cifs, as the error suggests. Maybe for whatever reason the Linux Mint mount.cifs doesn't support -o 'unc' or -o 'user'. It could be -o 'username=SOMETHING," but I can't remember all those. To read the manual pages:
man mount.cifs
Posts: 16
Joined: 1 Aug 2017

gcvdberg

I'm sorry, but it still doesn´t work. See the following command and result:
sudo mount -v -t cifs -o 'ip=192.168.178.17,unc=\\192.168.178.17\Public,user=George' //MyBookLive/Public /mnt/shares/Public
[sudo] wachtwoord voor pc-george:
ip address 192.168.178.17 override specified
Password for George@//MyBookLive/Public:  ************
mount.cifs kernel mount options: ip=192.168.178.17,unc=\\MyBookLive8.17\Public,unc=\\192.168.178.17\Public,user=George,pass=********
mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I consulted the mount.cifs manual page, but this is not extended enough. On the other hand, when googling for more info I found that the mount command can be very complicated. I think I need some more specialized knowledge. In between I use an ordinary external disk for backup purposes.

Maybe interesting, I found that I can enter the inside of the NAS with a SSH command. Then I can look into the NAS system with a terminal. It's a Debian system.
Posts: 306
Joined: 7 Jan 2018

bgstack15

I suspect the mount command is failing because of the duplicate UNC options. It's possible you don't need the UNC option listed at all, because the mount command is going ahead and putting it in the full command it tries to execute.
Or, it's possible the unc path should use forward slash / characters instead of the Windows-style backslash \ characters. Could you try:
sudo mount -v -t cifs -o 'ip=192.168.178.17,user=George' //MyBookLive/Public /mnt/shares/Public
The reason I have been unable to guide you more succinctly is because I don't actually use cifs at home anymore. I've got some at work, so maybe I'll check out those configs. But normally I just slap it in /etc/fstab and mount /mnt/directoryname.

Alternatively, to make sure you actually have samba connectivity to the server, you could try using the smbclient tool to help check the options needed to get a valid connection. It might not be useful, but it's out there. I personally have never used it. I always needed to mount filesystems like what you are trying to do.

Have you tried using the nfs connection at all? Here's a probably fstab entry:
mybooklive:/Public    /mnt/shares/Public        nfs    rw,bg,vers=4,rsize=65536,wsize=65536,hard,intr,proto=tcp,timeo=600,retrans=2
Or for the command line:
sudo mount -v -t nfs -o 'rw,bg,vers=4,rsize=65536,wsize=65536,hard,intr,proto=tcp,timeo=600,retrans=2' mybooklive:/Public /mnt/shares/Public
Posts: 16
Joined: 1 Aug 2017

gcvdberg

This is the result for the first command:
sudo mount -v -t cifs -o 'ip=192.168.178.17,user=George' //MyBookLive/Public /mnt/shares/Public
[sudo] wachtwoord voor pc-george:
ip address 192.168.178.17 override specified
Password for George@//MyBookLive/Public:  ************
mount.cifs kernel mount options: ip=192.168.178.17,unc=\\MyBookLive\Public,user=George,pass=********
mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
How can I try a nfs connection? (Remember, I'm a newbie!)

I put the command
mybooklive:/Public    /mnt/shares/Public        nfs    rw,bg,vers=4,rsize=65536,wsize=65536,hard,intr,proto=tcp,timeo=600,retrans=2
in the /etc/fstab. I understand that this is a kind of permanent mount procedure, isn't it? But it didn't work out.

And this is the result for your last suggestion:
sudo mount -v -t nfs -o 'rw,bg,vers=4,rsize=65536,wsize=65536,hard,intr,proto=tcp,timeo=600,retrans=2' mybooklive:/Public /mnt/shares/Public
[sudo] wachtwoord voor pc-george:
mount: wrong fs type, bad option, bad superblock on mybooklive:/Public,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
Thanks anyway for your help again.
Posts: 306
Joined: 7 Jan 2018

bgstack15

Ah, you might need to install package nfs-client or nfs-common. I don't remember the differences between them. I know some distros don't include the nfs packages by default, which confuses me. So, run:
sudo apt-get install nfs-common
Now, once you insert something in /etc/fstab, you need to run mount -av, but you don't need mount -a for the manual mount command.

But about the cifs command, I checked man 8 mount.cifs (on Ubuntu 16.04) again, and the parameter is username, not user. So you could try that.
Posts: 16
Joined: 1 Aug 2017

gcvdberg

Sorry for the delay. I installed nfs-common, and did again a lot of attempts, but it wasn't successful. I think it's getting to complicated for me now. I must go back to the base and learn all the ins and outs of mounting.
Thank you for all your help.
User avatar
Site Admin
Posts: 7052
Joined: 9 Dec 2007

Zenju

Maybe a little too late, but this command line works for me to mount a Samba share from Ubuntu 18.04:
 sudo mount -t cifs -o username=<name on SMB server>,password=<...>,\
     gid=1000,uid=1000 \
     //<IP of Samba Share>/<share name> ~/Desktop/<SMB folder>
The stuff marked by "< >" needs to be adapted accordingly and the "<SMB folder>" must be created previously.


Prerequisite is:
sudo apt-get install cifs-utils
Unmount again with:
sudo umount ~/Desktop/<SMB folder>
Posts: 16
Joined: 1 Aug 2017

gcvdberg

Thanks Zenju, you're not too late! I interpreted your suggestion as follows:
sudo mount -t cifs -o username=xxxxx,password=yyyyy, \gid=1000,uid=1000  //192.168.178.17/PCgeorge /mnt/shares/PCgeorge
Result:
,: command not found
The biggest differences with earlier attempts are the gid and uid options. Can you explain what these are and what 1000 means?
cifs-utils is installed.
User avatar
Site Admin
Posts: 7052
Joined: 9 Dec 2007

Zenju

The " \gid" part in your command line is not correct. "\" followed by a newline will concatenate the following line without any leading whitespace. IOW remove both the space and the "\" before "gid".

"gid=1000,uid=1000" will use your current login user (which I presume is 1000) when evaluating permissions of the mounted files. I believe because of the "sudo" the default is "root".
Posts: 16
Joined: 1 Aug 2017

gcvdberg

Now the command is as follows:
sudo mount -t cifs -o username=xxxxx,password=yyyyy,gid=1000,uid=1000 //192.168.178.17/PCgeorge /mnt/shares/PCgeorge
And the result:
,gid=1000,uid=1000: no such command (this is my translation from my Dutch version)
Hope you have an idea.