Skip to content

82 [sw][linux] linux/windows samba file share

Step 1 - Linux smb server

# install samba deps
sudo apt install samba smbclient
# enable & start samba sersvice
sudo systemctl start smbd.service
sudo systemctl enable smbd.service
sudo systemctl start nmbd.service
sudo systemctl enable nmbd.service
# add user to group
sudo usermod -a -G sambashare $USER
# set user password
sudo smbpasswd -a $USER
# config share path
# net usershare add <sharename> <sharepath> "<sharedesc>" Everyone:F guest_ok=n
net usershare add share $HOME "home" Everyone:F guest_ok=n
## /etc/samba/smb.conf
[share]
    path = /root
    writable = yes
    browsable = yes
    public = yes
    create mask = 0777
    directory mask = 0777
    force user = root
    max connections = 10

[share]
    path = /boot
    writable = yes
    browsable = yes
    public = yes
    create mask = 0777
    directory mask = 0777
    force user = root
    max connections = 10
# if you want to access softlink, use `mount --bind` or `fstab` instead
cd /root
mkdir boot
mount --bind /boot /root/boot
# fstab
/some/real/path  /srv/samba/share/mybind  none  bind  0  0
# test
smbclient //127.0.0.1/<sharename> -U <username>%<passwd>

Step 2 - Windows Client

Enable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol" -All
ping <your linux pc ip address>
- type \\<your linux ip>\<sharename> in windows explorer. - map a network disk by net use Z: \\<server>\<shared folder> /user:<name> <pswd> - use net use in cmd to list all connections


Comments

konosubakonoakua · 2024-09-23T16:58:09Z

linux mount windows shared

windows side

在 Windows 中通过网络共享文件

linux side

You may encounter mount read-only issue if cifs-utils is not installed.

sudo apt-get install cifs-utils

# create mount point
sudo mkdir -p /mnt/winshare
# list all sharenames
smbclient -L //10.9.8.7 -U user%password
sudo mount -t cifs //10.9.8.7/<sharename?> /mnt/winshare -o username=?,password=?
e.g.
sudo mount -t cifs //rf-pc-shiro.local/D/tools/petalinux /tools/petalinux/ -o username=RF-PC-SHIRO