VMware CentOS系统做Samba映射到Windows磁盘

一、Samba安装

这里要提一下,samba有四个软件包:

samba——>这个软件包包含了主要的daemon文件(smbd和nmbd)

samba-common——>提供samba的主要配置文件(smb.conf)、smb.conf语法检测程序(testparm)等

samba-client——> 当linux作为samba 客户端的时候,提供了一套所需的工具和指令
samba-samba——> 软件本体

然后安装不需要那么麻烦直接使用yum就可以了,所以依赖都解决。

1
yum install samba -y

二、使用步骤

1.直接改配置文件

1
vim /etc/samba/smb.conf

2.配置介绍

workgroup = WORKGROUP,这个WORKGROUP要和Windows物理机的工作组相对应

1
workgroup = WORKGROUP

3.我的/etc/samba/smb.conf配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
workgroup = WORKGROUP
security = user

passdb backend = tdbsam

printing = cups
printcap name = cups
load printers = yes
cups options = raw

[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes

[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No

[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775

三、最后添加用户

1.将root添加到samba账号里面,如果是其他账号就替换成你自己的账号,会提示输入两次密码,这个密码就是访问samba的密码

1
smbpasswd -a root

四、大功告成

1.重启samba服务

1
service smb restart

2.在CentOS虚拟机命令行中输入ip addr命令确定ip地址

3.如果没有ip地址先执行dhclient命令,然后再执行ip addr命令即可看到ip地址

4.在文件资源管理器地址栏输入\\IP地址\root,即可访问

5.设置为开机启动(可选)

1
systemctl enable smb

五、错误处理

1.windows访问报错:没有访问权限

修改/etc/sysconfig/selinux

1
vim /etc/sysconfig/selinux

把SELINUX=enforcing改为SELINUX=disabled

1
2
3
4
5
6
7
8
9
10
11
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
Author: chacebai
Link: http://www.spyhex.com/2024/vmware-centos-samba-map/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.