300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 【Linux】【开发环境】【RHEL】开发环境搭建系列之十——Linux主机环境下挂载samba服务器

【Linux】【开发环境】【RHEL】开发环境搭建系列之十——Linux主机环境下挂载samba服务器

时间:2019-07-31 20:35:21

相关推荐

【Linux】【开发环境】【RHEL】开发环境搭建系列之十——Linux主机环境下挂载samba服务器

在Windows下访问samba服务器比较容易,但是在Linux系统下访问samba服务器操作就略复杂了,本文将Linux服务器下访问samba服务器的步骤做一整理,供各位参考。

1、安装必要的软件

[qxhgd@localhost]$sudo yum install -y cifs-utils samba-client [qxhgd@localhost]$sudo yum install -y telnet

2、验证139端口是否开启:

[qxhgd@localhost]$telnet 192.168.2.100 139Trying 192.168.2.100...Connected to 192.168.2.100.Escape character is '^]'.

3、测试samba是否开了共享:

[qxhgd@localhost]$smbclient -L 192.168.2.100 -U qxhgdEnter SAMBA\qxhgd password:Sharename TypeComment --------- -----------print$DiskPrinter DriversIPC$ IPC IPC Service (Samba 3.3.14)qxhgdDiskHome DirectoriesReconnecting with SMB1 for workgroup listing.ServerComment--------- -------Workgroup Master--------- -------

4、挂载

4.1 准备挂载目录

[qxhgd@localhost]$sudo mkdir /mnt //默认mnt这个文件夹已存在[qxhgd@localhost]$sudo chmod -R 777 /mnt

4.2 手动挂载

[qxhgd@localhost]$mount -o vers=1.0,rw,uid=697260400,username="qxhgd",password="qxhgd" //192.168.2.100/qxhgd /mnt #法1、使用mount挂载[qxhgd@localhost]$sudo mount -t cifs -o vers=1.0,rw,uid=697260400,username="qxhgd",password="qxhgd" //192.168.2.100/qxhgd /mnt #法2、使用mount -t cifs挂载[qxhgd@localhost]$mount.cifs -o rw,dir_mode=0644,file_mode=0644,username="chiyanguang",password=“qxhgd” //192.168.2.100/qxhgd /mnt #法3、使用mount.cifs挂载

具体用哪个命令好用,可能和系统、环境有关系,

4.3 自动挂载

[qxhgd@localhost]$vim /etc/fstab//192.168.2.100/qxhgd /mnt cifs defaults,rw,dir_mode=0644,file_mode=0644,username=qxhgd,password=qxhgd 0 0[qxhgd@localhost]$mount -a #让系统重新挂载所有在/etc/fstab文件里面定义的挂载点,如果不执行,重启也可生效;

5、访问挂载的samba服务器内容

[qxhgd@localhost]$cd /mnt#和访问本地文件夹类似

6、取消挂载:

[qxhgd@localhost]$sudo umount /mnt

umount错误:device/target is busy问题的解决方案

方案0: 如果你的目的是重新挂载文件系统,请使用mount命令的remount参数

[qxhgd@localhost]$sudo mount -o remount /mnt//例如重新挂载mnt分区设备

方案1: 使用umount命令的 -f 选项强制卸载

[qxhgd@localhost]$sudo umount -f /mnt//-f选项会立即卸载分区

方案2: kill掉正在使用该分区设备的应用程序,然后再卸载设备

法1: 先sudo lsof /mnt查找进程,再kill或kill -9杀掉进程 (假设/mnt是挂载点)

法2: 先fuser /mnt 查找进程,再kill进程 (fuser的 -k 参数可以在查找进程的同时杀掉该进程)

如本文对你有些许帮助,欢迎大佬打赏:

支付宝及微信打赏方式

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。