Mount samba/SMB/CIFS persistently through fstab

Status
Not open for further replies.

nanopete

Dabbler
Joined
Nov 20, 2014
Messages
47
Hi!
This is part a newbie-guide how to mount a samba or CIFS share (without a password - guest account) in freenas and part a question as to why I had to do it like this to the wise-guys :)
Maybe those wiser guys could help make this into a prober newbie guide, I know I could have used that.

One can start by testing if the SMB or CIFS share can be mounted non-perstitently with a command like this;
Code:
mount_smbfs -I 192.168.1.1 //myUser@serverName/mySharedFolder /mnt/mySharedFolder

It is well explained here; http://blog.up-link.ro/freebsd-how-to-mount-smb-cifs-shares-under-freebsd/

To make it permanent (after reboots) you can put a similar command into your fstab file.
To get it into fstab you have to make the file system writeable by;
Code:
mount -uw /

You can then edit, not fstab at /etc/fstab, but /conf/base/etc/fstab which /etc/fstab is made from at each boot on freenas.
Code:
nano /conf/base/etc/fstab

In here put in your CIFS share info;
Code:
//myUser@serverName/mySharedFolder /mnt/mySharedFolder smbfs rw,-N,-I192.168.1.1 0 0

If you, as I, use a open guest account on the CIFS share you're good now after a reboot. Otherwise you need to put the user and password in a nsmb.conf file somewhere. (maybe it's the same as with fstab that it is made from something in /conf/base/etc/?)

I had little problem with /mnt/mySharedFolder because it seems /mnt/ is mounted on memory/RAM and everything you make in there disappears after a reboot? Am I correct?

Instead I made a folder in /media which will persist after a reboot, again you'll have to make the system writeable first.
Code:
mount -uw /
mkdir -755 /media/mySharedFolder
mount -ur /

And of cause here "mySharedFolder" can be anything you like as a mount point for the CIFS share. The 755 is the permissions of the new folder, not sure what permission is appropriate there, guess permissions would be a good thing to read up on :)

Best regards
Peter
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
Why not configure an init script with mount_smbfs command? See documentation here: http://doc.freenas.org/9.3/freenas_tasks.html#init-shutdown-scripts

I'm a bit stumped here though about why someone would do this. Permanently mounting CIFS shares on a file server is a bit odd, and mount_smbfs / smbclient are not particularly efficient (by default they are limited to NT1 / SMB1).
 
Last edited:

nanopete

Dabbler
Joined
Nov 20, 2014
Messages
47
Thanks for responding,
Well I am a newbie, as I hope my avatar illustrates (and happy)

A init script definitely seems a better way to go. Then you'll also have a better overview of what you've tinkered with, right there in the GUI. Thank you :)

I do it so my freenas-server has access to the space on my Synology NAS. Which I do because the non-redundant space on my Synology NAS is perfect for say movies I would'nt cry about if I lost. The Synology can't really run Plex-server, which my Freenas-server seems to excel at. I hope you haven't lost all respect for me because I use freenas as partly a media-server and partly a more reliable data-backup. Guess I'm an opportunist in regards of what I can use my old stationary (now freenas server with 8gb ram) and my 2-bay synology NAS for.
It does seem to be working as wanted.

I didn't know mount_smbfs was limited to SMB1, I actually thought CIFS was one of the best/fastest ways to share in you home network, maybe it still is if a different way than mount_smbfs is used?
I don't know what the better alternative is? I thought e.g. NFS wouldn't be much better.
I actually looked into setting up an iSCSI LUN target on my synology NAS, but it seems hard to get freenas working as an iSCSI initiator.
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
Thanks for responding,
Well I am a newbie, as I hope my avatar illustrates (and happy)

A init script definitely seems a better way to go. Then you'll also have a better overview of what you've tinkered with, right there in the GUI. Thank you :)

I do it so my freenas-server has access to the space on my Synology NAS. Which I do because the non-redundant space on my Synology NAS is perfect for say movies I would'nt cry about if I lost. The Synology can't really run Plex-server, which my Freenas-server seems to excel at. I hope you haven't lost all respect for me because I use freenas as partly a media-server and partly a more reliable data-backup. Guess I'm an opportunist in regards of what I can use my old stationary (now freenas server with 8gb ram) and my 2-bay synology NAS for.
It does seem to be working as wanted.

I didn't know mount_smbfs was limited to SMB1, I actually thought CIFS was one of the best/fastest ways to share in you home network, maybe it still is if a different way than mount_smbfs is used?
I don't know what the better alternative is? I thought e.g. NFS wouldn't be much better.
I actually looked into setting up an iSCSI LUN target on my synology NAS, but it seems hard to get freenas working as an iSCSI initiator.
The linux kernel CIFS driver (mount.cifs) supports SMB2/3, which is probably why this is a bit confusing. Don't worry. SMB1 is able to saturate gigabit. It is just less efficient and you may experience a bit more overhead during some file operations. NFS may be faster. I wouldn't bother with iSCSI. You can experiment with NFS, but it's hard to argue with a working configuration. :D Wait until you experience actual performance problems.
 
Last edited:

freebs

Cadet
Joined
Feb 24, 2015
Messages
3
Why not configure an init script with mount_smbfs command? See documentation here: http://doc.freenas.org/9.3/freenas_tasks.html#init-shutdown-scripts

I'm a bit stumped here though about why someone would do this. Permanently mounting CIFS shares on a file server is a bit odd, and mount_smbfs / smbclient are not particularly efficient (by default they are limited to NT1 / SMB1).
I did this and it works, but it asks for a password each time.
Do I create a passwd file ?
 

Admiral688

Dabbler
Joined
Apr 23, 2015
Messages
15
You can, however since it's not officially supported I keep the password off to prevent data corruption in case of any issues.
 

freebs

Cadet
Joined
Feb 24, 2015
Messages
3
ok, but it stops during a reboot waiting for a password.
I had to go downstairs and enter the pass.. before it would continue to boot.
So I would have to use a password file ...
 
Last edited:

Admiral688

Dabbler
Joined
Apr 23, 2015
Messages
15
Yea..... That's what happens unfortunately. I don't shut mine down often....... It's been down twice since I originally set it up....both times by a shutdown so I can definitely say this setup works perfectly fine.
 

toadman

Guru
Joined
Jun 4, 2013
Messages
619
I tried to get this working with the -N option of mount_smbfs, which should read the .nsmbrc file in users home directory (root in this case). No luck so far, it errors out.
 

pizzaazzip

Dabbler
Joined
Dec 3, 2015
Messages
25
ok, but it stops during a reboot waiting for a password.
I had to go downstairs and enter the pass.. before it would continue to boot.
So I would have to use a password file ...
Could you explain how to make a password file? I did a:

nano ~/.nsmbrc

and entered in information like this page into that file but it still ask for my password when it boots.
 

toadman

Guru
Joined
Jun 4, 2013
Messages
619
That's the same problem I had, the -N option was still asking for a password.

I never tried it as a mount from fstab as far as I remember. That requires the username:password in /etc/nsmb.conf I think.
 

pizzaazzip

Dabbler
Joined
Dec 3, 2015
Messages
25
That's the same problem I had, the -N option was still asking for a password.

I never tried it as a mount from fstab as far as I remember. That requires the username:password in /etc/nsmb.conf I think.
I'll give that a shot. I tried playing around with my fstab file last night and now my freenas setup goes into single user mode and won't go further :eek:. While last night it was a super huge deal, I'm sure I can fire up a copy of freebsd, mount my freenas boot usb, and just comment out the line I messed up. Once I do that, I'll see what the contents of /etc/nsmb.conf are and see if I can edit them to do what I want.
 
Status
Not open for further replies.
Top