Samba a FreeBSD compartint dos discs durs d'1TB en espill a la Raspberry Pi 2

Samba a FreeBSD compartint 2 discs durs d'1TB en espill a la Raspberry Pi 2

En aquest xicotet article vaig a explicar com compartir un disc dur d'1TB en un slot extern a la Raspberry Pi junt amb un altre disc d'1TB en espill sincronitzats. La idea és compartir dades personals (documents, fotos històriques, música, pelis, etc) a tots els dispositius BSD, Linux i Android de casa, instal·lant un servidor Samba a la Raspberry Pi 2 que arrancarà a l'inici.

Actualitzem fonts:

# pkg update -f

Busquem paquest del Samba:

# pkg search samba
p5-Samba-LDAP-0.05_2 Manage a Samba PDC with an LDAP Backend
p5-Samba-SIDhelper-0.0.0_3 Create SIDs based on G/UIDs
samba-nsupdate-9.8.6_1 nsupdate utility with GSS-TSIG support
samba45-4.5.16_1 Free SMB/CIFS and AD/DC server and client for Unix
samba46-4.6.14 Free SMB/CIFS and AD/DC server and client for Unix
samba47-4.7.6 Free SMB/CIFS and AD/DC server and client for Unix
samba48-4.8.0 Free SMB/CIFS and AD/DC server and client for Unix
[root@nuvolet /home/joan]#

Instal·lem samba ara:

# pkg install samba45
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 13 package(s) will be affected (of 0 checked):


New packages to be INSTALLED:
samba45: 4.5.16_1
libsunacl: 1.0.1
py27-dnspython: 1.15.0
tevent: 0.9.36
talloc: 2.1.11
py27-iso8601: 0.1.11
popt: 1.16_2
libinotify: 20180201
gamin: 0.1.10_9
tdb: 1.3.15_2,1
ldb: 1.1.29_1
libarchive: 3.3.2,1
lzo2: 2.10_1


Number of packages to be installed: 13


The process will require 141 MiB more space.
23 MiB to be downloaded.


Proceed with this action? [y/N]:

Ara configuraré el servidor Samba. Principalment vull compartir el disc dur 1 (ruta /mnt/disc1 a la Raspberry Pi 2) que tinc a un slot extern. Editem el fitxer /usr/local/etc/smb4.conf:

[global]
workgroup = WORKGROUP
server string = Server
security = user
encrypt passwords = yes
max log size = 500
preferred master = yes
hosts allow = 192.168.1.
interfaces = ue0
bind interfaces only = yes
socket options = TCP_NODELAY


[homes]
comment = User Home
browseable = no
writeable = yes
directory mask = 0700
create mask = 0700


[disc1]
comment = Disc1
path = /mnt/disc1
public = no
writeable = yes
write list = @admin
directory mask = 0770
create mask = 0770


[www]
comment = Web Root
path = /usr/local/www
public = no
writeable = yes
write list = @webadm
directory mask = 0775
create mask = 0775

Per a que FreeBSD arranque el Samba en l'arranc del sistema, cal que afegim a /etc/rc.conf/ el següent:

samba_server_enable="YES"

Ara creem un usuari 'joan' al Samba, i li afegirem una contrasenya:

# pdbedit -a -u joan
new password:
retype new password:
Unix username: joan
NT username:
Account Flags: [U ]
User SID: S-1-5-21-1403861561-1451000884-1333026714-1000
Primary Group SID: S-1-5-21-1403861561-1451000884-1333026714-513
Full Name: joan catala
Home Directory: \\nuvolet\joan
HomeDir Drive:
Logon Script:
Profile Path: \\nuvolet\joan\profile
Domain: NUVOLET
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: -1 seconds since the Epoch
Kickoff time: -1 seconds since the Epoch
Password last set: Tue, 22 May 2018 21:41:31 CEST
Password can change: Tue, 22 May 2018 21:41:31 CEST
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
[root@nuvolet /home/joan]#

Ordres interessants:
# smbcontrol all reload-config
# smbstatus
# smbtree

Iniciem i reiniciem Samba amb:

# /usr/local/etc/rc.d/samba_server stop
# /usr/local/etc/rc.d/samba_server start
Performing sanity check on Samba configuration: OK

O amb reload ja que, d'aquesta manera, no necessitem apagar el servidor samba i tornar a arrancar-lo i, d'aquesta manera, si algun usuari estava descarregant o copiant algun fitxer, no tindrà pèrdues:

# /usr/local/etc/rc.d/samba_server reload

Espere que trobes útil aquest article, i que et motive a compartir els teus trucs i coneixements i experiments amb el Programari Lliure. La Comunitat del Programari Lliure et necessita! :-)