Welcome! Log In Create A New Profile

Advanced

HOWTO : SAMBA / CIFS

Posted by Gravelrash 
HOWTO : SAMBA / CIFS
June 10, 2016 03:20AM
We will be configuring this with as an open share that everybody in the network will have read/write privilege


Install SAMBA Server and Client

apt-get update; apt-get upgrade -f -y; apt-get install samba cifs-utils --install-recommends -f -y;
Now its time to flush the disk(s) and reboot
sync; reboot

I will be making the following assumptions (just amend to suit your environment)

1. You already have a working system!
2. Your media to be shared is mounted via fstab by its label, in this case Disk1
3. The mounted disk resides in the following folder /media/Disk1
4. this mount has a folder inside called /Data

Configure Samba Server (as root)
mv /etc/samba/smb.conf /etc/samba/smb.conf.old
create a new smb.conf with teh following commands:
touch /etc/samba/smb.conf
nano /etc/samba/smb.conf
copy and past the following into the edited file
[global]
	server string = %h server
	map to guest = Bad User
	obey pam restrictions = Yes
	pam password change = Yes
	passwd program = /usr/bin/passwd %u
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
	unix password sync = Yes
	syslog = 0
#	log file = /var/log/samba/log.%m
	max log size = 1000
	client signing = required
	dns proxy = No
	usershare allow guests = Yes
	panic action = /usr/share/samba/panic-action %d
	idmap config * : backend = tdb
        socket options = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=131072 SO_RCVBUF=131072
        create mode = 777
        directory mode = 777
	interfaces = eth0
# 	bind interface only = yes

[DATA]
        delete readonly = yes
        writeable = yes
        browseable = yes
        public = yes
	guest ok  = Yes
	path = /media/Disk1/Data
Test the Samba conf file for any syntax error:
cd /etc/samba
testparm
If there is any error then it will tell you and show some indication where to look to fix.
if there are no errors you will see "normal" output of the test.

Restart Samba
service samba restart
Correct the permissions on the folder so anyone can read and write. To allow anonymous user access give the permissions as follows;
cd /media/Disk1
chmod -R 0755 Data/
chown -R nobody:nogroup Data/

Now anonymous users can browse & create file and folder contents.



Edited 14 time(s). Last edit at 06/25/2016 07:18AM by Gravelrash.
Re: HOWTO: SAMBA / CIFS
June 10, 2016 03:21AM
Reserved
Re: HOWTO: SAMBA / CIFS
June 10, 2016 03:21AM
Please post questions / comments / feedback here
Re: HOWTO : SAMBA / CIFS
June 12, 2016 05:42PM
Gravelrash,

>
> apt-get update; apt-get upgrade -f -y; apt-get
> install samba cifs-utils --install-recommends -f
> -y; sync; reboot;
>

I think this should be broken into 2 commands. If there is a break before the last 2 commands, if encoutered with errors in the 1st part then users will have a chance to gather more information and capture to a log file.
sync; reboot;

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : SAMBA / CIFS
June 12, 2016 06:12PM
bodhi Wrote:
-------------------------------------------------------
> encoutered with errors in the 1st part then users
> will have a chance to gather more information and
> capture to a log file.

@bodhi
Done!
Re: HOWTO : SAMBA / CIFS
June 24, 2016 11:26AM
Gravelrash Wrote:
-------------------------------------------------------
> bodhi Wrote:
> --------------------------------------------------
> -----
> > encoutered with errors in the 1st part then
> users
> > will have a chance to gather more information
> and
> > capture to a log file.
>
> @bodhi
> Done!

Samba install is not a problem. What I have an issue with, and that I've spent two, three days on is this:
automounting SAMBA shares using cifs

Here's my textbook fstab line that is not working:
//servername/sharename /media/windowsshare cifs credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm 0 0

And my latest error:
error 2 (No such file or directory) opening credential file /home/ubuntuusername/.smbcredentials

Since I created the .smbcredentials with root, I've replaced ubuntuusername with root. No cigar.
I'm testing on Ubuntu Wily and you name it, all that's needed, I've installed.
The server is on another box and has SAMBA server installed on it. And, yes, the server works well.
I can browse and connect to the shares on it.
But I want to automount, as would be good for the pogo
I'm about to give up, and install autofs on the pinkpogo, but thought, well drop this on the lap of the learned ones.
So! since the title on this thread mentions CIFS, well, I thought I'd be a bother. Anyone out there automounting SAMBA shares using CIFS?

If no answer, perhaps you say how you automount your SAMBA shares. At this point, I could care less what's out there, just what's working will do fine.
Re: HOWTO : SAMBA / CIFS
June 24, 2016 12:17PM
what you are looking for is what i actually do on my own Mint Laptop.

If i understand you correctly you are looking to mount the remote server share to your local workstation at boot time using /etc/fstab

please correct me if i am wrong.

what errors if any show up in your dmesg outptus?

do you have the correct codepage installed on your machine?

does the folder you are looking to mount into exist at teh path you specified?

try this :

edit you /etc/fstab and add the following

sudo nano /etc/fstab

modify your share / I.P. address / mount path to match your network
# Samba/CIFS mount

//192.168.10.254/DATA  /home/gravelrash/DATA  cifs  guest,uid=1000,iocharset=utf8  0  0

force fstab to "reload"
sudo mount -a

Let me know the outcome



Edited 5 time(s). Last edit at 06/24/2016 02:39PM by Gravelrash.
Re: HOWTO : SAMBA / CIFS
June 24, 2016 06:21PM
Gravelrash Wrote:
-------------------------------------------------------
> what you are looking for is what i actually do on
> my own Mint Laptop.
>
> If i understand you correctly you are looking to
> mount the remote server share to your local
> workstation at boot time using /etc/fstab
>
> please correct me if i am wrong.

You're quite correct. Only now I'm not using my pogo, testing instead on my laptop first. It's simply convenient for me.
>
> what errors if any show up in your dmesg outptus?

CIFS VFS: cifs_mount failed w/return code = -6

> do you have the correct codepage installed on your
> machine?
>
> does the folder you are looking to mount into
> exist at teh path you specified?

Yes, I created a new one as well, focusing to ensure that I'm not doing so as "root" Because one of the many errors I've had, when mounting via Thunar: "mount: only root can mount //192.x.x.x.x.x...."
>
> try this :
>
> edit you /etc/fstab and add the following
>
>
> sudo nano /etc/fstab
>
>
> modify your share / I.P. address / mount path to
> match your network
>
> # Samba/CIFS mount
> 
> //192.168.10.254/DATA  /home/gravelrash/DATA  cifs
>  guest,uid=1000,iocharset=utf8  0  0
>
>
> force fstab to "reload"
>
> sudo mount -a
>
>
> Let me know the outcome

Aside what is above, in terminal, I get:
"mount.nfs: Connection timed out
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)"

I've done this, thinking without the password file, I'd be good to go. No cigar.
There has to be something. Can you share the details of your setup?
Many thanks.
Re: HOWTO : SAMBA / CIFS
June 25, 2016 07:16AM
Very happy to share my setup.

The software installation on server is done as per the instructions above. below is my SERVER smb.conf
[global]
	server string = %h server
	map to guest = Bad User
	obey pam restrictions = Yes
	pam password change = Yes
	passwd program = /usr/bin/passwd %u
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
	unix password sync = Yes
	syslog = 0
#	log file = /var/log/samba/log.%m
	max log size = 1000
	client signing = required
	dns proxy = No
	usershare allow guests = Yes
	panic action = /usr/share/samba/panic-action %d
	idmap config * : backend = tdb

# MY MODS
        socket options = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=131072 SO_RCVBUF=131072
        create mode = 777
        directory mode = 777
	interfaces = eth0

[DATA]
        delete readonly = Yes
        writeable = Yes
        public = Yes
	guest ok = Yes
	path = /mnt/SATA/DATA
	browseable = Yes

server /etc/fstab (standard mounts removed)
# Self Mounted

# Standard HDD
LABEL=DATA      /mnt/SATA       ext4    suid,errors=continue,dev,noatime,exec   0       2

# Additional USB disk
# LABEL=1TB     /mnt/usb        ext4    errors=continue,dev,noatime     0       2

# Swapdisk
/dev/sda1       swap    swap    defaults        0       0

The software installation on Client is done as per the instructions above for SERVER. below is my Client smb.conf
# Global parameters
[global]
	server string = %h server (Samba, Linux Mint)
	server role = standalone server
	map to guest = Bad User
	obey pam restrictions = Yes
	pam password change = Yes
	passwd program = /usr/bin/passwd %u
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
	unix password sync = Yes
	syslog = 0
	log file = /var/log/samba/log.%m
	max log size = 1000
	name resolve order = bcast host
	dns proxy = No
	usershare allow guests = Yes
	panic action = /usr/share/samba/panic-action %d
	idmap config * : backend = tdb


[printers]
	comment = All Printers
	path = /var/spool/samba
	create mask = 0700
	printable = Yes
	browseable = No


[print$]
	comment = Printer Drivers
	path = /var/lib/samba/printers

/etc/fstab with standard mounts removed for clarity
# Self Mounted
# remote Data share
//192.168.2.200/DATA  /home/gravelrash/DATA  cifs  guest,uid=1000,iocharset=utf8  0  0

Re: HOWTO : SAMBA / CIFS
June 25, 2016 01:58PM
Gravelrash Wrote:
-------------------------------------------------------
> Very happy to share my setup.
>
> The software installation on server is done as per
> the instructions above. below is my SERVER
> smb.conf
>
> [global]
> 	server string = %h server
> 	map to guest = Bad User
> 	obey pam restrictions = Yes
> 	pam password change = Yes
> 	passwd program = /usr/bin/passwd %u
> 	passwd chat = *Enter\snew\s*\spassword:* %n\n
> *Retype\snew\s*\spassword:* %n\n
> *password\supdated\ssuccessfully* .
> 	unix password sync = Yes
> 	syslog = 0
> #	log file = /var/log/samba/log.%m
> 	max log size = 1000
> 	client signing = required
> 	dns proxy = No
> 	usershare allow guests = Yes
> 	panic action = /usr/share/samba/panic-action %d
> 	idmap config * : backend = tdb
> 
> # MY MODS
>         socket options = SO_KEEPALIVE TCP_NODELAY
> IPTOS_LOWDELAY SO_SNDBUF=131072 SO_RCVBUF=131072
>         create mode = 777
>         directory mode = 777
> 	interfaces = eth0
> 
> [DATA]
>         delete readonly = Yes
>         writeable = Yes
>         public = Yes
> 	guest ok = Yes
> 	path = /mnt/SATA/DATA
> 	browseable = Yes
>
>
> server /etc/fstab (standard mounts removed)
>
> # Self Mounted
> 
> # Standard HDD
> LABEL=DATA      /mnt/SATA       ext4   
> suid,errors=continue,dev,noatime,exec   0       2
> 
> # Additional USB disk
> # LABEL=1TB     /mnt/usb        ext4   
> errors=continue,dev,noatime     0       2
> 
> # Swapdisk
> /dev/sda1       swap    swap    defaults        0 
>      0
>
>
> The software installation on Client is done as per
> the instructions above for SERVER. below is my
> Client smb.conf
>
> # Global parameters
> [global]
> 	server string = %h server (Samba, Linux Mint)
> 	server role = standalone server
> 	map to guest = Bad User
> 	obey pam restrictions = Yes
> 	pam password change = Yes
> 	passwd program = /usr/bin/passwd %u
> 	passwd chat = *Enter\snew\s*\spassword:* %n\n
> *Retype\snew\s*\spassword:* %n\n
> *password\supdated\ssuccessfully* .
> 	unix password sync = Yes
> 	syslog = 0
> 	log file = /var/log/samba/log.%m
> 	max log size = 1000
> 	name resolve order = bcast
> host
> 	dns proxy = No
> 	usershare allow guests = Yes
> 	panic action = /usr/share/samba/panic-action %d
> 	idmap config * : backend = tdb
> 
> 
> [printers]
> 	comment = All Printers
> 	path = /var/spool/samba
> 	create mask = 0700
> 	printable = Yes
> 	browseable = No
> 
> 
> [print$]
> 	comment = Printer Drivers
> 	path = /var/lib/samba/printers
> 
>
>
> /etc/fstab with standard mounts removed for
> clarity
>
> # Self Mounted
> # remote Data share
> //192.168.2.200/DATA  /home/gravelrash/DATA  cifs 
> guest,uid=1000,iocharset=utf8  0  0
> 
>

Thanks a lot. This looks good and it's obviously working. Except for the server side, I have much of what you have here. My SAMBA config is different from yours, but that can't be the problem. I'm willing to be proven wrong.

Anyone here with experience setting up autofs? I think I'm done with this for now. I'm beginning to suspect it's my version of Ubuntu. But then again, the pogo won't mount the SAMBA share either.

Thanks a lot. If I work more on it and get results, I will create a thread, if others think it necessary.
Re: HOWTO : SAMBA / CIFS
June 25, 2016 04:05PM
might be better if you share your /etc/fstab and /etc/samba/smb.conf so we can examine and see where the issue lies
Re: HOWTO : SAMBA / CIFS
June 26, 2016 03:33AM
notoneofmyseeds,

> Anyone here with experience setting up autofs? I
> think I'm done with this for now. I'm beginning to
> suspect it's my version of Ubuntu. But then again,
> the pogo won't mount the SAMBA share either.

Go ahead and google autofs, or start here. This Ubuntu tutorial is basically the same as used on any Debian distro:
https://help.ubuntu.com/community/Autofs

When you are setting it up, any problem or questions then post them. I'm not near my plugs so I can not post a good tutorial for autofs.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 06/26/2016 03:35AM by bodhi.
Re: HOWTO : SAMBA / CIFS
June 26, 2016 02:57PM
bodhi Wrote:
-------------------------------------------------------
> notoneofmyseeds,
>
> > Anyone here with experience setting up autofs?
> I
> > think I'm done with this for now. I'm beginning
> to
> > suspect it's my version of Ubuntu. But then
> again,
> > the pogo won't mount the SAMBA share either.
>
> Go ahead and google autofs, or start here. This
> Ubuntu tutorial is basically the same as used on
> any Debian distro:
> https://help.ubuntu.com/community/Autofs
>
> When you are setting it up, any problem or
> questions then post them. I'm not near my plugs so
> I can not post a good tutorial for autofs.

Thanks bohdi for that link. I've seen and read it.

OK, I will take a dip and may emerge with a HowTo.

See you soon...in the forum.
cde
Re: HOWTO : SAMBA / CIFS
March 04, 2020 08:59PM
For a server only, only do "apt-get install samba" so none of that exim4 or cron or other noisy cruft is installed. Just python and some basic libs. Clean and minimal.

cifs-utils is only needed for a Samba client.

I have "force user" and "force group" set to the same user and group I mount my HD as (fat32), so I don't need to change the mount command or permissions for that share for any user that connects. Alternatively you can set "guest account" to do so just for guest connections.

And "public" is the same as "guest ok", so no need to have both.
Re: HOWTO : SAMBA / CIFS
March 09, 2020 05:40AM
if you would like to do a more specific server only howto based around the newer kernel and libs, that would be much appreciated


The above HOWTO was correct at time of writing and included the option to connect from the plug to another windows share.



cde Wrote:
-------------------------------------------------------
> For a server only, only do "apt-get install samba"
> so none of that exim4 or cron or other noisy cruft
> is installed. Just python and some basic libs.
> Clean and minimal.
>
> cifs-utils is only needed for a Samba client.
>
> I have "force user" and "force group" set to the
> same user and group I mount my HD as (fat32), so I
> don't need to change the mount command or
> permissions for that share for any user that
> connects. Alternatively you can set "guest
> account" to do so just for guest connections.
>
> And "public" is the same as "guest ok", so no need
> to have both.
Re: HOWTO : SAMBA / CIFS
March 22, 2020 01:46AM
Dear experts!!! Who can help correct the error that comes out when you install < samba >. Already broke his head as soon as I didn 't act on advice from the Internet nothing works. Purpose, install and configure < samba > This is what comes out in the terminal.
login as: root
root@192.168.1.42's password:
Linux debian 5.2.9-kirkwood-tld-1 #1 PREEMPT Sat Aug 17 15:00:56 PDT 2019 armv5tel

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Mar 21 22:40:36 2020 from 192.168.1.47
root@debian:~# sudo DEBCONF_DEBUG=developer apt install -f
Reading lists of packages … It is ready
Creation of a tree of dependences
Reading status information... It is ready
0 packages updated, 0 new packages installed, 0 packages marked for deletion, and 0 packages not updated.
Not up to 2 packets installed or deleted.
After this operation, the amount of disk space used will increase by 0 B.
Configuring samba-common-bin package (2:4.9.5 + dfsg-5 + deb10u1)...
Checking smb.conf with testparm
Load smb config files from /etc/samba/smb.conf
Error loading services.
Dpkg: Error processing samba-common-bin (--configure) packet:
installed samba-common-bin package post-installation script subprocess returned error exit status 1
Dpkg: Packet dependencies do not allow to configure samba package:
Samba depends on samba-common-bin (= 2:4.9.5 + dfsg-5 + deb10u1), however:
The samba-common-bin package has not yet been configured.

Dpkg: Error processing samba package (--configure):
Dependency issues - leave not configured
Errors occurred while processing the following packets:
samba-common-bin
samba
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@debian:~#
Re: HOWTO : SAMBA / CIFS
March 29, 2020 10:54AM
Having an issue with the mounting size of an a external USB to the pogoplug. I followed the direction to setup in the wiki and everything is working pretty well but the size of the share shows up as 15gigs (the size of the boot stick not the external usb (12TB)). The drive itself is writeable from certain applications - blue iris was writing to it directly without an issue. Copying files over manually though every time shows that the size of the drive is not big enough for the files.. even though there is more than enough room. Really frustrating. Can someone help?

Here is what shows with fdisk -l

Disk /dev/sdb: 10.9 TiB, 12000138625024 bytes, 23437770752 sectors
Disk model: easystore 25FB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 06E8968B-6B83-498C-BCE6-E7605C0A85B4

Device Start End Sectors Size Type
/dev/sdb1 2048 23437768703 23437766656 10.9T Linux filesystem



Edited 1 time(s). Last edit at 03/29/2020 11:20AM by Timmons.
Re: HOWTO : SAMBA / CIFS
March 29, 2020 04:59PM
Timmons,

This seems to be an old quirk with Samba. I forgot to tell Gravelrash to add the solution to the tutorial.

> the size of the share
> shows up as 15gigs (the size of the boot stick not
> the external usb (12TB)).

> Copying files over manually though every time
> shows that the size of the drive is not big enough
> for the files.. even though there is more than
> enough room.

When you export the share mountpoint at the top folder /media, Window Explorer might not see the real capacity of the USB drives underneath . I'm not sure if just a few versions of Windows SAMBA/CIFS or all versions behave this way.

To help Windows seeing the real capacity , you need to mount the share at the mount point of the disk. For example, if you export the share at /media/sdb1, Windows will see it correctly. For my usual approach, I always use a disk label and mount the USB disk at that mountpoint.

So I make sure the USB disk has a label

e2label /dev/sdb1 MUSIC
And then either mount it manually using pmount
pmount -o noatime /dev/sdb1 MUSIC
or use my udev rules to automount when it is plugged in:

https://forum.doozan.com/read.php?2,24139

And add that to the smb.conf

[MUSIC]
        delete readonly = yes
        writeable = yes
        browseable = yes
        public = yes
	guest ok  = Yes
	path = /media/MUSIC

After that, from Windows Explorer, you will see the correct capacity of 12 TB.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : SAMBA / CIFS
March 31, 2020 02:12PM
Thank you. Worked like a charm
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: