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

  1. 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.

  2. Check network connectivity:

    • Run ping 8.8.8.8 in the terminal. If you see round-trip time information returned, the network is functioning normally.

  3. 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 root user login with no password by default.

Install Samba Service

Samba is a service program on Debian/Linux used for sharing files with Windows systems.

  1. Update the package list:

sudo apt-get update

💡 If the development board currently cannot directly access Debian software repositories, you can first download arm64 .deb installation packages on the host, then copy them to the development board and install them using dpkg -i. At minimum, you need to prepare samba-common, samba-common-bin, samba, and smbclient. If versions are inconsistent, you must also include the corresponding version dependency libraries.

  1. 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.

  1. Verify Samba installation success:

smbd --version
smbclient --version
sudo samba -V

Create Shared Folder

💡 This document uses user q as an example for Samba sharing configuration. If this user has not been created on the system, you can use an existing user (such as root), or create a regular user first before continuing with the configuration.

  1. Create the shared directory:

mkdir -p /home/q/share
  1. Create a test file:

touch /home/q/share/test.txt
  1. Modify permissions:

chmod -R 777 /home/q/share

Configure Samba Service

  1. Open the configuration file:

sudo vim /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf
  1. 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 is q. 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 = no and guest ok = no. Choose based on your actual needs. To allow anonymous access, use public = yes (M1 approach); to disallow anonymous/guest access, keep public = 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 root as 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.

Access Windows Shared Folders from the Device

In addition to accessing the device’s shared directory from a Windows computer, you can also access shared folders on the Windows computer from the device in the reverse direction.

Create Shared Directory on Windows

  1. Create a new folder on the Windows computer for sharing, for example:

device_share
  1. Right-click the folder, select “Properties” → “Sharing” → “Advanced Sharing”.

  2. Check “Share this folder” and set the share name to:

    • L1 device: Recommended l1_share

    • M1 device: Recommended m1_share

m1_share    (M1)
l1_share    (L1)
  1. Click “Permissions” and add read or write permissions for the Windows user who needs to access this shared directory.

  2. Switch to the “Security” tab and confirm that the Windows user also has the corresponding read or write permissions in NTFS permissions.

💡 Both Windows share permissions and “Security” permissions need to allow access simultaneously; otherwise, the device side may be able to see the share name but cannot enter the directory or create files.

Verify Network and Firewall on Windows

  1. Confirm that the Windows computer and the device are on the same reachable network. In the testing documented here, the Windows host IP is 10.66.84.17 (M1 environment example).

  2. In Windows “Advanced Sharing Settings”, enable:

    • Network discovery

    • File and printer sharing

  3. Confirm that the Windows firewall allows “File and Printer Sharing (SMB-In)”.

Check Connectivity from the Device

Run the following commands in the device terminal to confirm access to the Windows host’s SMB service ports (replace <Windows主机IP> with the actual IP; M1 tested with 10.66.84.17):

# 查看设备当前IP地址
hostname -I

# 测试Windows主机网络连通性
ping -c 3 <Windows主机IP>

# 测试SMB端口连通性
timeout 3 bash -c 'cat < /dev/null > /dev/tcp/<Windows主机IP>/445' && echo 445_open || echo 445_failed
timeout 3 bash -c 'cat < /dev/null > /dev/tcp/<Windows主机IP>/139' && echo 139_open || echo 139_failed

If the output shows 445_open or 139_open, it indicates that the device can reach the Windows SMB service ports.

Access via Command Line from the Device

Use smbclient to view the share list on the Windows host:

smbclient -L //<Windows主机IP> -U 'DOMAIN\\username'

Example (using the tested M1 Windows IP 10.66.84.17):

smbclient -L //10.66.84.17 -U 'QUECTEL\\username'

Enter the Windows user’s login password as prompted. If authentication succeeds, you should see the shared directory names in the output, for example:

m1_share        Disk

Access a specific shared directory and list its files:

smbclient //<Windows主机IP>/<共享名> -U 'DOMAIN\\username' -c 'ls'

Example (using M1):

smbclient //10.66.84.17/m1_share -U 'QUECTEL\\username' -c 'ls'

In testing documented here, the device can successfully list the Windows host’s share list and enter the corresponding shared directory.

Access via Graphical Interface from the Device (M1 Only)

💡 This method applies to the M1 GNOME graphical environment. For the L1 Weston environment, use the command-line method for access.

In the Quectel Pi M1 Debian graphical environment, you can access Windows shared directories through the file manager. Enter the following in the file manager address bar:

smb://10.66.84.17/m1_share

Then follow the on-screen prompts to enter the Windows username, domain or workgroup, and password to access the shared directory.

Access Device Shared Folders from Windows Computer

  1. Press “Win+R” to open the Run window.

  2. Enter the device’s shared access path, for example:

\\\\<开发板IP>\\myshare
\\\\10.66.84.182\\myshare
  1. Enter the username and password to see the contents of the shared folder.

    • Username: The user specified by valid users in the Samba configuration (q for M1)

    • Password: The password set when running smbpasswd -a ``

  2. After successful access, you should see the previously created test file test.txt.