Openwrt 使用终端挂载共享硬盘

Openwrt 使用终端挂载共享硬盘

我这里使用的是R2S软路由挂载的SATA硬盘,通过usb2.0接口外接硬盘,速度只有30M左右,后续升级。

使用的R2S里面没有网络共享的页面,只能使用终端进行配置。

查看挂载信息

root@ImmortalWrt:/etc/samba# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                29.1G    508.4M     28.6G   2% /
tmpfs                   493.7M     22.5M    471.3M   5% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mmcblk0p1           63.0M     15.3M     46.3M  25% /mnt/mmcblk0p1
/dev/sda1                 1.7T    331.1G      1.4T  19% /pm863

查看挂载的硬盘

查看系统检查的硬盘(可以查看到未挂载的)

安装lsblk

root@ImmortalWrt:/dev# opkg install lsblk
Multiple packages (libgcc1 and libgcc1) providing same name marked HOLD or PREFER. Using latest.
Multiple packages (libgcc1 and libgcc1) providing same name marked HOLD or PREFER. Using latest.
Installing lsblk (2.38.1-1) to root...
Downloading https://mirrors.tencent.com/lede/snapshots/packages/aarch64_generic/base/lsblk_2.38.1-1_aarch64_generic.ipk
Installing libmount1 (2.38.1-1) to root...
Downloading https://mirrors.tencent.com/lede/snapshots/packages/aarch64_generic/base/libmount1_2.38.1-1_aarch64_generic.ipk
Configuring libmount1.
Configuring lsblk.

查看

root@ImmortalWrt:/dev# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda           8:0    0  1.7T  0 disk
└─sda1        8:1    0  1.7T  0 part /pm863
mmcblk0     179:0    0 29.7G  0 disk
├─mmcblk0p1 179:1    0   64M  0 part /mnt/mmcblk0p1
└─mmcblk0p2 179:2    0 29.6G  0 part /

samba4注册用户

注册openwrt用户hongda

安装 shadow-common shadow-useradd

root@ImmortalWrt:/etc/samba# opkg install shadow-common
Multiple packages (libgcc1 and libgcc1) providing same name marked HOLD or PREFER. Using latest.
Installing shadow-common (4.8.1-3) to root...
Downloading https://mirrors.tencent.com/lede/snapshots/packages/aarch64_generic/packages/shadow-common_4.8.1-3_aarch64_generic.ipk
Configuring shadow-common.
root@ImmortalWrt:/etc/samba# opkg install shadow-useradd
Multiple packages (libgcc1 and libgcc1) providing same name marked HOLD or PREFER. Using latest.
Installing shadow-useradd (4.8.1-3) to root...
Downloading https://mirrors.tencent.com/lede/snapshots/packages/aarch64_generic/packages/shadow-useradd_4.8.1-3_aarch64_generic.ipk
Configuring shadow-useradd.

新增用户

root@ImmortalWrt:/etc/samba# useradd hongda
root@ImmortalWrt:/etc/samba# passwd hongda
Changing password for hongda
New password:
Bad password: similar to username
Retype password:
passwd: password for hongda changed by root

注册samba用户hongda,设置密码

root@ImmortalWrt:/etc/samba# smbpasswd -a hongda
New SMB password:
Retype new SMB password:
Added user hongda.

删除用户

root@ImmortalWrt:/mnt/883dct# smbpasswd -x hongda
Deleted user hongda.

samba4 配置

路径:

/etc/samba/smb.confg.template
[883-DCT]
    path = /mnt/883dct
    valid users = hongda,@root
    admin users = hongda,@root
    writable = yes
    read only = no
    create mask = 0666
    directory mask = 0755
    browseable = yes
    inherit owner = yes

校验配置格式

root@ImmortalWrt:/etc/samba# testparm -v

校验通过以后,重启samba4

root@ImmortalWrt:/etc/samba# service samba4 restart
root@ImmortalWrt:/etc/samba# service samba4 status
running

参考:

openwrt上设置SAMBA4共享,并且指定用户密码

Openwrt下折腾 Samba4 配置

posted @ 2023-03-22 21:28  hongdada  阅读(2804)  评论(0编辑  收藏  举报