由于电视盒子送的影视会员到期了,那上面很多电影又需要承担“巨额”的会员费用才能观看,所以想通过设备互联观看从互联网下载到电脑里的影视资源。
实现思路是由主机下载个人平时收集在阿里云盘的影视资源,将主机上的下载路径通过vmware workstation的文件共享功能挂在到centos的samba共享目录,在电视机系统或者电视盒子上通过共享目录功能连接,就能直接看到影视文件所在的目录了。(windows系统也可以部署samba直接共享目录,但笔者还需要主机的linux环境编写文件共享给笔记本,所以这里使用linux部署)
tips: Samba可以用于Linux与windows系统直接的文件共享和打印共享,Samba既可以用于windows与Linux之间的文件共享,也可以用于Linux与Linux之间的资源共享,由于NFS(网络文件系统)可以很好的完成Linux与Linux之间的数据共享,因而 Samba较多的用在了Linux与windows之间的数据共享上面。
前置准备工作:
1.安装VMware workstation
2.在VMware workstation中安装centos系统
3.centos7虚拟机网卡模式设置为桥接,如果主机上有多个网卡,注意选择桥接到与电视机同一路由器下的网卡。
centos7 samba部署操作:
mkdir /etc/yum.repos.d/bak&&mv /etc/yum.repos.d/* /etc/yum.repos.d/bak/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum install samba samba-common -y
systemctl enable smb.service vim /etc/samba/smb.conf #修改samba主配置文件如下
[global]workgroup = SAMBAsecurity = usermap to guest = Bad User #公开,无需用户登录passdb backend = tdbsamprinting = cupsprintcap name = cupsload printers = yescups 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
[public]comment = "BD's movies" #描述,随意填写path = /share/public/ # 分享资源的完整路径名称,除了路径要正确外,目录的权限也要设对writable = yes #写入权限browseable =yes # 是yes/否no在浏览资源中显示共享目录,若为否则必须指定共享路径才能存取guest ok =yes # 是yes/否no公开共享,若为否则进行身份验证(只有当security = share 时此项才起作用) public =yes # 是yes/否no公开共享,若为否则进行身份验证(只有当security = share 时此项才起作用)systemctl restart smb.service
vmware workstation共享文件夹:
点击“安装VMware tools(T)“ 笔者此处已经安装完毕,所以只有重新安装的选项。
此时在系统内输入命令lsblk可以看到多了一个"sr0"设备,挂在到mnt下,然后拷贝出压缩文件,解压,再安装:
[root@c7-bd ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 128G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 123G 0 part /
sr0 11:0 1 55.9M 0 rom
[root@c7-bd ~]# mount /dev/sr0 /opt
mount: /dev/sr0 is write-protected, mounting read-only
[root@c7-bd ~]# ls /opt/
manifest.txt run_upgrader.sh VMwareTools-10.3.23-16594550.tar.gz vmware-tools-upgrader-32 vmware-tools-upgrader-64
[root@c7-bd ~]# cp /opt/VMwareTools-10.3.23-16594550.tar.gz ~/
[root@c7-bd ~]# ls
anaconda-ks.cfg scripts test.txt VMwareTools-10.3.23-16594550.tar.gz
[root@c7-bd ~]# tar -zxcf VMwareTools-10.3.23-16594550.tar.gz
[root@c7-bd scripts]# cd vmware-tools-distrib/
[root@c7-bd vmware-tools-distrib]# ls
bin caf doc etc FILES INSTALL installer lib vgauth vmware-install.pl
[root@c7-bd vmware-tools-distrib]# ./vmware-install.pl 然后一直按回车 yes
此时已经安装好插件,在vmware workstation 设置中将存在影视资源的路径进行共享:
用命令可以看到已经共享成功,然后再linux系统中进行挂载:
[root@c7-bd vmware-tools-distrib]# vmware-hgfsclient #查看共享目录
ali_download
[root@c7-bd vmware-tools-distrib]#mkdir /share/public
[root@c7-bd vmware-tools-distrib]#chmod -R 777 /share/public
[root@c7-bd vmware-tools-distrib]# vmhgfs-fuse .host:/ali_download /share/public -o allow_other #挂载共享文件夹,注意一定要加-o allow_other 给予普通用户root权限,否则共享出去后其他系统上无法访问
[root@c7-bd vmware-tools-distrib]# ls /share/public/
desktop.ini Marvels.Daredevil.S02E09.1080p.NF.WEBRip.Chs-IFA.mp4
Marvels.Daredevil.S02E03.1080p.NF.WEBRip.Chs-IFA.mp4 Marvels.Daredevil.S02E10.1080p.NF.WEBRip.Chs-IFA.mp4
Marvels.Daredevil.S02E04.1080p.NF.WEBRip.Chs-IFA.mp4 Marvels.Daredevil.S02E11.1080p.NF.WEBRip.Chs-IFA.mp4
Marvels.Daredevil.S02E05.1080p.NF.WEBRip.Chs-IFA.mp4 Marvels.Daredevil.S02E12.1080p.NF.WEBRip.Chs-IFA.mp4
Marvels.Daredevil.S02E06.1080p.NF.WEBRip.Chs-IFA.mp4 Marvels.Daredevil.S02E13.1080p.NF.WEBRip.Chs-IFA.mp4
Marvels.Daredevil.S02E07.1080p.NF.WEBRip.Chs-IFA.mp4 英雄无归.4K.真蓝光.KLWNH.内嵌中字.mp4
Marvels.Daredevil.S02E08.1080p.NF.WEBRip.Chs-IFA.mp4
部署完毕,可以在其他同网络设备上查看,或挂载。
windows:按win+e 在路径中输入\\IP\目录:
linux:
mount -t cifs -o username=用户名,password=密码 //IP/共享目录 /挂载点/share/
电视: