有的Ubuntu系统不能通过虚拟机的文件夹共享功能实现Windows与Ubuntu之间的文件共享,可以通过安装samba实现这个功能,主要步骤如下,供参考。经过测试,我的Ubuntu12.4.2系统已经可以实现在Windows下访问Ubuntu系统中的文件夹,当然Ubuntu12.4.2是可以通过虚拟机共享功能访问Windows中文件夹。有了这个功能后,就可以将Ubuntu中编译的文件共享到Windows。
一、更新源
[email protected]:~$ su
Password:
[email protected]:/home/openwrt# apt-get update
二、安装Samba服务
[email protected]:/home/openwrt# apt-get install -y samba
[email protected]:/home/openwrt# apt-get install -y smbfs
三、创建共享目录,修改目录权限
[email protected]:/home/openwrt# mkdir -p /home/shareFiles
[email protected]:/home/openwrt# chmod 777 /home/shareFiles/
[email protected]:/home/openwrt# ll -d /home/shareFiles/
drwxrwxrwx 2 root root 4096 May 7 01:59 /home/shareFiles/
四、为了防止Samba的配置文件被破坏,先对原来的配置文件做个备份,再配置
[email protected]:/home# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
[email protected]:/home# vi /etc/samba/smb.conf
添加如下内容:
[share]
path = /home/komy/share
available = yes
browseable = yes
public = yes
writable = yes
五、添加Samba用户
[email protected]:/home/openwrt# touch /etc/samba/smbpasswd
[email protected]:/home/openwrt# useradd smbuser
[email protected]:/home/openwrt# smbpasswd -a smbuser
New SMB password:
Retype new SMB password:
Added user smbuser.
[email protected]:/home/openwrt#
六、启动Samba服务
[email protected]:/home/openwrt# /etc/init.d/smbd restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service smbd restart
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop smbd ; start smbd. The restart(8) utility is also available.
smbd stop/waiting
smbd start/running, process 8278
[email protected]:/home/openwrt#
七、在Windows下测试\\10.117.42.105,可以访问到Ubuntu中的文件夹了
如若不能访问,出现权限问题请关闭Linux的防火墙和安全Linux,重启Linux后再测试。
[email protected]:/home/openwrt# service ufw stop
[email protected]:/home/openwrt# apt-get install selinux-utils
[email protected]:/home/openwrt# setenforce 0
setenforce: SELinux is disabled