Samba File Sharing¶
Overview¶
Samba is a commonly used tool for building file sharing and access control services on Linux systems. It uses the SMB protocol to enable cross-device file access within a local network. By deploying Samba locally, you can conveniently provide shared directories to Windows, Linux, or macOS clients, enabling cross-platform file transfer and collaboration.
This document describes how to configure the Samba file sharing service on a Quectel Pi (M1 / L1) Debian system, allowing a Windows computer to directly access the device’s shared folders.
Prerequisites¶
Verify the device environment:
The device (M1 or L1) can connect to the network normally
The Windows host and the device are on the same local network
M1 has been verified under the GNOME graphical environment. L1 has been verified under the Weston graphical environment. Samba file sharing does not depend on the GNOME desktop.
Check network connectivity:
Run
ping 8.8.8.8in the terminal. If you see round-trip time information returned, the network is functioning normally.
Log in to the development board (L1 only):
If the local debug environment is already available, you can also enter the system via ADB; this document uses serial port login as an example.
For serial connection methods, refer to: debug_uart.md
L1 defaults to
rootuser login with no password by default.
Install Samba Service¶
Samba is a service program on Debian/Linux used for sharing files with Windows systems.
Update the package list:
sudo apt-get update
💡 If the development board currently cannot directly access Debian software repositories, you can first download
arm64.debinstallation packages on the host, then copy them to the development board and install them usingdpkg -i. At minimum, you need to preparesamba-common,samba-common-bin,samba, andsmbclient. If versions are inconsistent, you must also include the corresponding version dependency libraries.
Install Samba and client tools:
sudo apt-get install samba
sudo apt-get install smbclient
💡
samba: Server-side software for providing sharing services;smbclient: Client tool for testing whether the connection is successful.
Verify Samba installation success:
smbd --version
smbclient --version
sudo samba -V
Configure Samba Service¶
Open the configuration file:
sudo vim /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf
Scroll to the end of the file and add the following content:
[myshare]
comment = My Shared Folder
browseable = yes
path = /home/q/share
create mask = 0777
directory mask = 0777
valid users = q
force user = q
force group = q
public = no
guest ok = no
writable = yes
available = yes
💡
[myshare]— The share name visible when accessed from a Windows client.path— The actual path of the shared directory.create mask / directory mask— Default permissions for newly created files/folders.valid users— Valid users allowed to access the Samba server. The example user here isq. In actual use, replace this with a real user on the development board.writable = yes— Allows clients to create, modify, and delete files in this directory.
💡 On M1,
public = yes; on L1,public = noandguest ok = no. Choose based on your actual needs. To allow anonymous access, usepublic = yes(M1 approach); to disallow anonymous/guest access, keeppublic = no, guest ok = no(L1 approach).
Set Samba User and Password¶
Samba login users require a separately set password. Using the system user q as an example:
sudo smbpasswd -a q
You need to enter the password twice to confirm (this password will be used when accessing from Windows).
💡 If using
rootas the Samba login user (default L1 scenario), replace the above command with:sudo smbpasswd -a root.
Restart Samba Service to Apply Configuration¶
sudo systemctl restart smbd
Set Samba to start automatically on boot:
sudo systemctl enable smbd
Add Firewall Rules¶
#添加放行端口
sudo iptables -A INPUT -p tcp -m tcp --dport 445 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 139 -j ACCEPT
#设置客户端IP允许通过防火墙
sudo iptables -A INPUT -p icmp --icmp-type echo-request -s 192.xx.xx.xx -j ACCEPT
#保存规则
sudo sh -c 'iptables-save > /etc/iptables/rules.v4'
View Device IP Address¶
hostname -I
In actual use, use the IP address currently queried on the development board.