有些朋友喜欢在PVE上安装黑群晖当文件服务器。由于中间隔了VMM,个人觉得性能太低。还是喜欢直接在pve主机上安装smb文件共享服务。 1、安装samba服务apt update && apt install samba -y 2、设置配置文件可以在/etc/samba/smb.conf末尾中添加 #添加一个iso共享库 [iso] //此处是路径,例如//10.13.14.2/iso comment = this is a iso //描述 path = /var/lib/vz/template //共享的文件夹 guest ok = no //不允许访客 browseable = no //不允许浏览 write list = root //运行root读写 懒人可以一键开启 cat >>/etc/samba/smb.conf <<EOF [iso] comment = this is a iso path = /var/lib/vz/template guest ok = no browseable = no write list = root EOF 3、添加用户smbpasswd -a root 4、重启smb服务systemctl restart smbd 5、验证6、如果不想使用root用户在实际环境中,可能 有多个用户,当然不能将root共享出去。 6.1 新建账户#新增系统用户 useradd smbuser1 useradd smbuser2 useradd smbuser3 #新增smb用户 smbpasswd -a smbuser1 smbpasswd -a smbuser2 smbpasswd -a smbuser3 6.2 创建共享文件夹mkdir /var/smb/smbuser1 -p mkdir /var/smb/smbuser2 -p mkdir /var/smb/smbuser3 -p
并且在目录里面,创建文件 6.3 修改文件夹权限chown -R smbuser1 /var/smb/smbuser1/ chown -R smbuser2 /var/smb/smbuser2/ chown -R smbuser3 /var/smb/smbuser3/ 6.4 添加配置文件在 /etc/samba/smb.conf 中添加 [smbuser1] comment = smbuser1 files path = /var/smb/smbuser1 guest ok = no browseable = no write list = smbuser1 [smbuser2] comment = smbuser2 files path = /var/smb/smbuser2 guest ok = no browseable = no write list = smbuser2 [smbuser3] comment = smbuser3 files path = /var/smb/smbuser3 guest ok = no browseable = no write list = smbuser3 cat >> /etc/samba/smb.conf <<EOF [smbuser1] comment = smbuser1 files path = /var/smb/smbuser1 guest ok = no browseable = no write list = smbuser1 [smbuser2] comment = smbuser2 files path = /var/smb/smbuser2 guest ok = no browseable = no write list = smbuser2 [smbuser3] comment = smbuser3 files path = /var/smb/smbuser3 guest ok = no browseable = no write list = smbuser3 EOF #重启服务 systemctl restart smbd 6.5 验证一下搭建好的速度
7、开启SMB脚本下面是一个便捷开启Smb的脚本,并且配置了local和root目录的共享。默认共享账号为root,密码为root
请使用命令,新建一个smb.sh文件,将上述内容给粘贴上去,执行命令bash smb.sh即可开始安装。 随后在Windows上访问即可 (责任编辑:IT) |