不折腾会死:CentOS7访问小米路由(Samba服务)

由于之家里电脑之前是用win10的,访问小米路由(1T硬盘版)只需要按win + r输入\\192.168.31.1即可访问到小米路由硬盘中的目录和文件。

但是最近系统换成CentOS,想继续像以前那样访问小米路由,于是折腾了一番,以下是笔记。

1) 安装samba:yum -y install samba samba-client samba-winbind,查看已安装的samba组件:

[cai@beta-cat ~]$ rpm -qa | grep samba
samba-common-4.4.4-14.el7_3.noarch
samba-winbind-modules-4.4.4-14.el7_3.x86_64
samba-4.4.4-14.el7_3.x86_64
samba-client-libs-4.4.4-14.el7_3.x86_64
samba-winbind-4.4.4-14.el7_3.x86_64
samba-client-4.4.4-14.el7_3.x86_64
samba-libs-4.4.4-14.el7_3.x86_64
samba-common-libs-4.4.4-14.el7_3.x86_64
samba-common-tools-4.4.4-14.el7_3.x86_64

2) 查询小米路由信息:smbclient -L 192.168.31.1 -U admin%1234,其中admin是小米路由的管理员帐号,1234是密码。(即你平时在浏览器输入miwifi.com显示的登陆页面上输入的帐号密码),我查询的信息出来是这样的:

[cai@beta-cat ~]$ smbclient -L 192.168.31.1 -U admin%1234
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.0.21]
 
        Sharename       Type      Comment
        ---------       ----      -------
        XiaoMi          Disk      
        XiaoMi-usb0     Disk      

从上面可以看到XiaoMi就是小米路由的共享目录,还有一个我插在小米路由上的U盘XiaoMi-usb0

手动挂载(重启后要重新挂载)

手动挂载小米路由硬盘到CentOS目录:sudo mount -t cifs -l //192.168.31.1/XiaoMi /mnt/XiaoMi

[cai@beta-cat ~]$ sudo mount -t cifs -l //192.168.31.1/XiaoMi /mnt/XiaoMi
[sudo] password for cai: 
Password for root@//192.168.31.1/XiaoMi:  ********

就这样,你就可以在CentOS的/mnt/XiaoMi目录看到小米路由的硬盘上的目录和文件了。

自动挂载(开机自动挂载)

1) 创建一个文件,用于存储小米路由的帐号密码:
sudo vi /etc/samba/xiaomi.conf,xiaomi.conf加入帐号密码配置:

username=admin
password=1234

2) 编辑/etc/fstab文件,在最后加入配置:

#
# /etc/fstab
# Created by anaconda on Sun Aug 27 23:39:15 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl_miwifi--r2d--srv-root /                       xfs     defaults        0 0


//192.168.31.1/XiaoMi                /mnt/XiaoMi             cifs    defaults,credentials=/etc/samba/xiaomi.conf    0    0
//192.168.31.1/XiaoMi-usb0           /mnt/XiaoMi-usb0        cifs    defaults,credentials=/etc/samba/xiaomi.conf    0    0

3) 重新挂载:sudo mount -a

4) 查看挂载:sudo mount,我的显示如下:

//192.168.31.1/XiaoMi on /mnt/XiaoMi type cifs ......

//192.168.31.1/XiaoMi-usb0 on /mnt/XiaoMi-usb0 type cifs (rw,relatime,vers=1.0,cache=strict,username=admin,domain=CMI,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.31.1,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)

参考文章:
samba 服务器手动挂载&&自动挂载

你可能感兴趣的:(小米路由器,samba,linux,centos7)