家庭NAS搭建实战之samba共享

Posted jks212454

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了家庭NAS搭建实战之samba共享相关的知识,希望对你有一定的参考价值。

家庭NAS搭建实战之samba共享

一、系统环境

root@onecloud:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@onecloud:~# 

二、配置仓库源

1.备份原有仓库源

cp  /etc/apt/sources.list  /etc/apt/sources.listbak   #备份原有配置文件

2.配置新debain源

deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
#deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
#deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

3.更新debain源

apt-get update

二、安装samba软件

1.安装软件

root@onecloud:/var/lib/dpkg# apt-get install -y   samba

2.设置共享目录

mkdir -p /data/NAS/nas

3.设置共享目录权限

root@onecloud:~# chmod 777 /data/NAS/nas/
root@onecloud:~# ls -ld /data/NAS/nas/
drwxrwxrwx 3 root root 4096 Jan 24 22:53 /data/NAS/nas/

4.新建samba用户


root@onecloud:~# groupadd it
root@onecloud:~# useradd -g it admin
root@onecloud:~# sabpasswd -a admin


root@onecloud:~# smbpasswd -a admin
New SMB password:
root@onecloud:~# smbpasswd -a admin
New SMB password:
Retype new SMB password:
Added user admin.

5.查看smba用户列表

root@onecloud:~# pdbedit -L
admin:1003:
root@onecloud:~# 

三、修改samba配置文件

root@onecloud:~# vim /etc/samba/smb.conf
[share]
      path = /data/NAS/nas/
      browseable = yes
      write list = @it
      hosts allow = 192.168.3.0/24

四、测试配置文件

root@onecloud:~# testparm /etc/samba/smb.conf 
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
	idmap config * : backend = tdb


[share]
	path = /data/NAS/nas/
	hosts allow = 192.168.3.0/24
	write list = @it
root@onecloud:~# 

五、设置开机自启服务

root@onecloud:~# systemctl start smbd
root@onecloud:~# systemctl enable smbd
Synchronizing state of smbd.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable smbd
root@onecloud:~# 

六、测试登录

windows电脑登录

以上是关于家庭NAS搭建实战之samba共享的主要内容,如果未能解决你的问题,请参考以下文章

如何利用 BTSync 搭建私有云储存

Linux NAS存储文件共享

《畅玩NAS》家庭 NAS 服务器搭建方案

《畅玩NAS》家庭 NAS 服务器搭建方案

NFS服务搭建及数据无缝迁移

Linux之SAMBA文件共享服务器