每次搭建Linux Ubuntu虚拟机都要配置的samba,方法与大家share一下:
1. 安装samba和系统共享模块
$ sudo apt-get install samba
$ sudo apt-get installkdenetwork-filesharing
2. 创建samba共享目录
$ mkdir /home/samba
$ chmod 777 /home/samba (注意这里一定要修改)
3. 备份并编辑smb.conf允许网络用户访问
$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
$ sudo vi /etc/samba/smb.conf
a. 在smb.conf最后增加如下内容:
[ubuntu_samba]
comment = arm ubuntu samba dir
path = /home/samba
available = yes
browseable = yes
public = yes
writable = yes
create mask = 0777
security = share
force user = nobody
* arm force group = nogroup //ubuntu14.04版本安装samb 4.3.11不需要这个配置
b. 找到workgroup = MSHOME这一行,用如下几行代替,注意是代替,目的是为了防止中文目录乱码
workgroup = WORKGROUP
display charset = UTF-8
unix charset = UTF-8
dos charset = cp936
4. 测试并重启samba
sudo service smbd restart
---------------------------------------------到这里samba就配置完成了,通过windows就可以访问共享目录了
************************遇到的问题解决方法*****************
1、不能访问共目录
sudo apt-get install libtalloc2
2、查看log,定位问题原因
$ sudo testparm
// 注:如果出现"执行子进程“testparm”失败"的信息,需要安装
$ apt-get installsamba-common-bin
正常成功的打印如下:
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Unknown parameter encountered: "display charset"
Ignoring unknown parameter "display charset"
Processing section "[ubuntuOS]"
Global parameter security found in service section!
Global parameter smb passwd file found in service section!
Global parameter encrypt passwords found in service section!
Processing section "[printers]"
Processing section "[print$]"
Processing section "[Share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
按Enter键会显示Samba的共享目录信息