Mounting SMB shares

ThomasHall

Dabbler
Joined
Jun 5, 2019
Messages
14
I'm having some trouble with mounting SMB shares in FreeNAS and would appreciate some help. The problem is actually two-fold, so I'll start with the background and context.

What I've got is:
  • 1x Windows 10 desktop
  • 1x MicroServer Gen10 FreeNAS 11.2-U5 (2x4TB pool + 1xSSD pool, 2 shares total)
  • 1x Zyxel NAS326 (1x8TB disk, 2 shares total)
The plan is to use the server to store files and export the pools to the desktop, an Ubuntu VM in the FreeNAS that I've not yet created, and whatever other device I might want. The NAS326 I'll use as a place to backup files that I keep on both the desktop and the server and nothing else. FreeNAS is mostly configured, though I've got some stuff left to do e.g. snapshots. The desktop can mount these shares no problem. The issue is the NAS326, and like I said, there are 2 of them.

As it is, the NAS has 2 shares set up, "Desktop-Backup" and "Server-Backup". I discovered that there were some problems with file names where the NAS itself would display names either with missing characters (WebGUI) or with a ? in place of the character (ls in terminal). In the W10 file explorer, these files would just show up with no name or extension, unable to be read. The characters in question were anything not strict ASCII, for example things like ´ é ü å ä ö etc. It made things complicated when trying to manage them too, and my only option was basically to SSH to the NAS, go root, and then do something like "rm abc*" and hope no other files matched.

After a lot of fiddling, I discovered that adding/changing
unix charset = UTF-8
dos charset = ISO8859-1
display charset = ISO8859-1
in the NAS' smb.conf file made it so that files I copied to the NAS showed up correctly on both the NAS and the W10 mount. With the exception of the fact that this file resets whenever I reboot the NAS, that seems to do the trick, though I'm not really sure what it does to be honest other than adjusting the expected character encoding for different devices I assume.

Anyway, then came the time to mount these shares to FreeNAS. First problem is, how do I do that properly? Using the following command on FreeNAS worked, technically, but I'm not sure if that's what I should be using:
mount_smbfs -W WORKGROUP -I 192.168.1.200 //admin@NAS326/Desktop-Backup /mnt/Zyxel
However, I've also read that I should be using "mount -t cifs ..." instead, but I can't seem to get the format correct, or some settings are wrong.

Either way, working with the assumption that the mount_smbfs command is okay, I run into another issue, which is again the file names. If I create files at one of the devices, I get different results. "a.txt" shows up correctly on both W10, NAS and FreeNAS. If I create "ä.txt" and "ö.txt" on the desktop or the NAS respectively, it shows up correctly on itself and the other, but not on FreeNAS which will display them as "?.txt". If I create "å.txt" on FreeNAS, it'll display correctly on FreeNAS, but show up as "Ã¥.txt" on the other devices. I'm suspecting this is once again some issue with the character encoding, but I have no clue what I'm supposed to do about it.

Here's the output of smbstatus and the smb.conf file on the NAS:
Code:
~ # smbstatus
Ignoring unknown parameter "display charset"
Ignoring unknown parameter "display charset"

Samba version 4.1.7
PID     Username      Group         Machine
-------------------------------------------------------------------
5239|admin|everyone|freenas|ipv4:192.168.1.201:62758
30857|admin|everyone|192.168.1.250|ipv4:192.168.1.250:52095

Service      pid     machine       Connected at
-------------------------------------------------------
Server-Backup|30857|192.168.1.250|2019-08-20 09:50:28
Desktop-Backup|30857|192.168.1.250|2019-08-20 09:50:28
Desktop-Backup|5239|freenas|2019-08-20 03:27:59

Locked files:
Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time
--------------------------------------------------------------------------------------------------
30857        501        DENY_ALL   0x100080    RDONLY     NONE             /i-data/32856d84/Server-Backup   .   Tue Aug 20 10:14:32 2019
30857        501        DENY_NONE  0x100081    RDONLY     NONE             /i-data/32856d84/Desktop-Backup   .   Tue Aug 20 10:22:44 2019
30857        501        DENY_NONE  0x100081    RDONLY     NONE             /i-data/32856d84/Desktop-Backup   .   Tue Aug 20 10:22:48 2019


192.168.1.201 is my FreeNAS server, 250 is my desktop, and 200 is the NAS326 itself. As you might be able to tell, I currently have both shares mounted on the desktop and only "Desktop-Backup" mounted on FreeNAS for experimenting.
Code:
~ # cat /etc/samba/smb.conf
[global]
        workgroup = WORKGROUP
        server string = ""
        netbios name = NAS326
        unix charset = UTF-8
        dos charset = ISO8859-1
        display charset = ISO8859-1
        security = user
        encrypt passwords = yes
        smb passwd file = /etc/samba/smbpasswd
        guest account = pc-guest
        encrypt passwords = yes
        map to guest = Bad User
        write ok = yes
        force create mode = 777
        force directory mode = 777
        auth methods = guest sam_ignoredomain
        max log size = 50
        host msdfs = yes
        lanman auth = yes
        kernel oplocks = no
        socket options = IPTOS_LOWDELAY TCP_NODELAY SO_SNDBUF=2048000 SO_RCVBUF=2048000
        max xmit = 131072
        level2 oplocks = no
        max smbd processes = 128
        printing = cups
        printcap = /etc/printcap
        load printers = yes
        use sendfile = yes
        passdb backend = smbpasswd
        unix extensions = no
        wide links = yes
        veto files = /.grive*/.dropbox*/.THIS_IS_RECYCLE_BIN/.RBM/
        min receivefile size = 8192
        store dos attributes = yes

[printers]
        path = /i-data/.media/samba
        public = yes
        guest ok = yes
        browseable = yes
        writable = no
        printable = yes
        use client driver = yes

[Server-Backup]
        path = /i-data/32856d84/Server-Backup
        follow symlinks = yes
        strict allocate = yes
        allocation roundup size = 0
        aio write size = 4096
        comment = ""
        browseable = yes
        valid users = "admin"

[Desktop-Backup]
        path = /i-data/32856d84/Desktop-Backup
        follow symlinks = yes
        strict allocate = yes
        allocation roundup size = 0
        aio write size = 4096
        comment = ""
        browseable = yes
        valid users = "admin"


Again, this file is reset on reboots, so I can't make permanent changes to it unless I figure out some way around that. As it's just a backup host though, I can just make changes manually and restart the service whenever I plug it in for running a backup.

Originally the dos charset was "ASCII" and the display charset wasn't there at all (smbstatus seems to indicate this is ignored anyway). The unix charset was "UTF8", but I don't know if that makes a difference and examples I looked at used "UTF-8", so I don't know.

So I guess the questions are basically:
  1. What's the proper way to mount an SMB share in FreeNAS/Ubuntu (bonus points for persistent mounting too, e.g. fstab entry)?
  2. How do I ensure proper character encoding across multiple platforms while doing it?
I'm new to most of this so I've been forced to do a lot of learning (hopefully) in a very short time. Feels like I've run into a wall right now though. Any help is much appreciated.
 

ThomasHall

Dabbler
Joined
Jun 5, 2019
Messages
14
The NAS326 is not very friendly when it comes to settings. I can create folders that are implicitly shared with SMB and... well, that's pretty much it as far as I can tell. I'm not terribly concerned about security issues as this particular NAS will only exist on my own private network and will spend most of the time unplugged anyway, so it's basically just an external hard drive for multiple devices.

I'd happily mount it in FreeNAS in whatever way works, the main issue is the charset, since I suspect backups may get tricky if certain files on the target drive can't be read properly.
 

Fredda

Guru
Joined
Jul 9, 2019
Messages
608
If you can't configure it, it is probably not possible to do what you want. Do you really need SMB for that?

If you can ssh into the Zyxel NAS, you can probably use scp to move files.
If you can create NFS shares on the Zyxel NAS, you can try that.

Anyway, mounting shares into the FreeNAS is not really a supported mode of operation...
 

ThomasHall

Dabbler
Joined
Jun 5, 2019
Messages
14
I'm trying to come up with the easiest way to backup multiple devices to a single one over the network. I figured using SMB would be the most simple method (I briefly tried NFS, but I didn't understand how permissions/ownership worked). I figured having the backup shares mounted on all the devices I want to backup would be the most flexible solution as I could use whatever backup software is available as long as it can sync two drives/folders and not worry about how it is mounted. From what I've read, getting rsync to work with a Zyxel device as the target is a pain, in part because apparently they use some version of rsync they made themselves that is not compatible with the standard rsync. But I'm open to suggestions for better alternatives on how to handle it.

Anyway, I just managed to get it working, I think. It's really, really dumb if this is it, at least IMO.
This command that I've tried before didn't work, didn't mount anything and gave no error message or reaction at all for that matter:
mount_smbfs -E utf8:utf8 -W WORKGROUP -I 192.168.1.200 //admin@NAS326/Desktop-Backup /mnt/Zyxel
This one that I tried just now did:
mount_smbfs -W WORKGROUP -I 192.168.1.200 -E utf8:utf8 //admin@NAS326/Desktop-Backup /mnt/Zyxel
And that makes the characters consistent across W10, FreeNAS and NAS326, at least the "å" character which I tested with. I have no idea why reordering those options worked, nothing in the help implies that's necessary (if anything, it implies the -E should come first).

Still can't get the mount command to work, e.g.
mount -t cifs -o user=admin,workgroup=WORKGROUP,iocharset=utf8 //192.168.1.200/Desktop-Backup /mnt/Zyxel
Just spits out an "Operation not supported by device" error, which is not very encouraging, but I'm not sure if that's because the NAS326 can't do it or because I'm writing the command wrong. I'm tempted to just call it a day and use the mount_smbfs version, but I don't know if there are any disadvantages of note.
 

ThomasHall

Dabbler
Joined
Jun 5, 2019
Messages
14
You can add these as "auxiliary parameters" under Services->SMB. Once you do this they will persist across restarts.

On the FreeNAS server, yes, but I'm trying to modify it on the Zyxel NAS, where I've yet to find any officially supported method whatsoever to modify SMB settings.
 
Top