Samba is a implementation of the SMB/CIFS networking protocol that is used by Windows devices to provide shared access to files, printers, and serial ports etc. There is a comprehensive Wikipedia page about Samba and its capabilities.
Samba 是 SMB/CIFS 网络协议的实现,该协议被 Windows 设备用于共享访问文件、打印机和串行端口等。
维基百科上有一个综合介绍 Samba 及其作用的页面。
This page will explain how to use a subset of the Samba system to ‘mount’ a shared folder on a Windows device so it appears on your Raspberry Pi, or to share a folder on your Raspberry Pi so it can be accessed by a Windows client.
这个页面将解释如何使用 Samba 系统的子集在 Windows 设备上安装一个共享文件夹,这样它就会出现在你的 Raspberry Pi 上,
或者在你的 Raspberry Pi 上共享一个文件夹并且可以被 Windows 客户端访问。
By default, Raspbian does not include CIFS/Samba support, but this can easily be added. The following commmands will install all the required components for using Samba as a server or a client.
默认Raspbian 不包含 CIFS/Samba 支持,但是这很容易添加。 下面的命令将安装使用 Samba 作为服务器或客户端所需的所有组件。
sudo apt-get update
sudo apt-get install samba samba-common-bin smbclient cifs-utils
First, you need to share a folder on your Windows device. This is quite a convoluted process!
首先,你需要在 Windows 设备上共享一个文件夹。 这是一个相当复杂的过程!
You can share any folder you want, but for this example, simply create a folder called share
.
你可以共享任何你想共享的文件夹,但是在这个例子中,简单起见就创建一个名为 share 的文件夹。
share
on your desktop.The folder should now be shared.
该文件夹现在应该被共享。
On Windows 10 there is a Sharing Wizard that helps with some of these steps.
在 windows10上有一个分享向导,它可以帮助你完成这些步骤。
Mounting* in Linux is the process of attaching a folder to a location, so firstly we need that location.
在 Linux 中挂载是将一个文件夹连接到一个位置的过程,首先我们需要这个位置。
mkdir windowshare
Now, we need to mount the remote folder to that location. The remote folder is the host name or IP address of the Windows PC, and the share name used when sharing it.
We also need to provide the Windows username that will be used to access the remote machine.
现在,我们需要将远程文件夹挂载到该位置。远程文件夹是 Windows PC 的主机名或 IP 地址,以及共享时使用的共享名称。
我们还需要提供用于访问远程计算机的 Windows 用户名。
sudo mount.cifs //<hostname or IP address>/share /home/pi/windowshare -o user=<name>
You should now be able to view the content of the Windows share on your Raspberry Pi.
现在你应该可以在你的 Raspberry Pi 上查看 Windows 分享的内容。
cd windowshare
ls
Firstly, create a folder to share. This example creates a folder called shared
in the home
folder of the current user, and assumes the current user is pi
.
首先,创建一个文件夹来共享。这个例子是在当前用户的家目录下创建一个名为 share 的文件夹,并假设当前用户是 pi。
cd ~
mkdir shared
Now we need to tell Samba to share this folder, using the Samba configuration file.
现在我们需要告诉 Samba 共享这个文件夹,通过使用 Samba 配置文件。
sudo nano /etc/samba/smb.conf
At the end of the file, add the following to share the folder, giving the remote user read/write permissions:
在文件的末尾,添加以下来分享文件夹,给予远程用户读写权限:
[share]
path = /home/pi/shared
available = yes
valid users = pi
read only = no
browsable = yes
public = yes
writable = yes
In the same file, find the workgroup
line, and if necessary, change it to the name of the workgroup of your local Windows network.
在同一个文件中,查找workgroup
所在的行,如果有必要可以将其更改为本地 Windows 网络的工作组名称。
workgroup = <your workgroup name here>
That should be enough to share the folder. On your Windows device, when you browse the network, the folder should appear and you should be able to connect to it.
这些对于分享这个文件夹来说应该足够了。在你的 Windows 设备上浏览网络时,文件夹应该会出现,你也应该可以连接到它。