由于在Linux板子之间实现NFS文件系统挂载实现较为困难,所以改为sshfs文件系统挂载,下面一步步探索sshfs挂载的流程和实验。首先在2个虚拟机Linux系统之间测试sshfs相互挂载,然后使用buildroot编译sshfs下载到Linux板子中测试。

ubuntu 18.04

查看IP地址

logread@logread:~$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.201.132  netmask 255.255.255.0  broadcast 192.168.201.255inet6 fe80::20c:29ff:fe38:3f29  prefixlen 64  scopeid 0x20<link>ether 00:0c:29:38:3f:29  txqueuelen 1000  (Ethernet)RX packets 7256  bytes 9496942 (9.4 MB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 1688  bytes 170434 (170.4 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

安装sshfs软件

logread@logread:~$ sudo apt-get install fuse-sshfs
[sudo] password for logread:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package fuse-sshfs
logread@logread:~$ sudo apt-get install sshfs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:sshfs
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 41.3 kB of archives.
After this operation, 114 kB of additional disk space will be used.
Get:1 https://mirrors.aliyun.com/ubuntu bionic/universe amd64 sshfs amd64 2.8-1 [41.3 kB]
Fetched 41.3 kB in 0s (102 kB/s)
Selecting previously unselected package sshfs.
(Reading database ... 120266 files and directories currently installed.)
Preparing to unpack .../archives/sshfs_2.8-1_amd64.deb ...
Unpacking sshfs (2.8-1) ...
Setting up sshfs (2.8-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
logread@logread:~$ 

查看sshfs版本

logread@logread:~$ sshfs --version
SSHFS version 2.8
FUSE library version: 2.9.7
fusermount version: 2.9.7
using FUSE kernel interface version 7.19

查看支持的sshfs文件系统

logread@logread:~$ cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   ramfs
nodev   bdev
nodev   proc
nodev   cpuset
nodev   cgroup
nodev   cgroup2
nodev   tmpfs
nodev   devtmpfs
nodev   configfs
nodev   debugfs
nodev   tracefs
nodev   securityfs
nodev   sockfs
nodev   dax
nodev   bpf
nodev   pipefs
nodev   hugetlbfs
nodev   devptsext3ext2ext4squashfsvfat
nodev   ecryptfsfuseblk
nodev   fuse
nodev   fusectl
nodev   pstore
nodev   mqueuebtrfs
nodev   autofs

CentOS 7.3

查看IP地址

[yubo.wang@localhost ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.201.130  netmask 255.255.255.0  broadcast 192.168.201.255inet6 fe80::890e:5af4:e734:af0d  prefixlen 64  scopeid 0x20<link>ether 00:0c:29:33:16:9e  txqueuelen 1000  (Ethernet)RX packets 15717  bytes 21012818 (20.0 MiB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 4633  bytes 442424 (432.0 KiB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

安装sshfs软件

[yubo.wang@localhost ~]$ sudo yum install fuse-sshfs
[sudo] password for yubo.wang:
Loaded plugins: auto-update-debuginfo, fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                        | 3.6 kB  00:00:00
base-debuginfo                                              | 2.5 kB  00:00:00
epel/x86_64/metalink                                        | 9.4 kB  00:00:00
epel                                                        | 4.7 kB  00:00:00
epel-debuginfo/x86_64/metalink                              | 9.3 kB  00:00:00
epel-debuginfo                                              | 3.0 kB  00:00:00
extras                                                      | 2.9 kB  00:00:00
updates                                                     | 2.9 kB  00:00:00
(1/7): epel/x86_64/group_gz                                 |  95 kB  00:00:00
(2/7): epel/x86_64/updateinfo                               | 1.0 MB  00:00:00
(3/7): extras/7/x86_64/primary_db                           | 165 kB  00:00:00
(4/7): epel/x86_64/primary_db                               | 6.8 MB  00:00:00
(5/7): epel-debuginfo/x86_64/primary_db                     | 803 kB  00:00:00
(6/7): updates/7/x86_64/primary_db                          | 7.6 MB  00:00:01
(7/7): base-debuginfo/x86_64/primary_db                     | 2.8 MB  00:06:33
Determining fastest mirrors* base: mirrors.aliyun.com* epel: mirrors.aliyun.com* epel-debuginfo: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package fuse-sshfs.x86_64 0:2.10-1.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved===================================================================================Package              Arch             Version                Repository      Size
===================================================================================
Installing:fuse-sshfs           x86_64           2.10-1.el7             epel            50 kTransaction Summary
===================================================================================
Install  1 PackageTotal download size: 50 k
Installed size: 103 k
Is this ok [y/d/N]: y
Downloading packages:
fuse-sshfs-2.10-1.el7.x86_64.rpm                            |  50 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : fuse-sshfs-2.10-1.el7.x86_64                                    1/1 Verifying  : fuse-sshfs-2.10-1.el7.x86_64                                    1/1 Installed:fuse-sshfs.x86_64 0:2.10-1.el7                                                   Complete![yubo.wang@localhost ~]$ sshfs --version
SSHFS version 2.10
FUSE library version: 2.9.2
fusermount version: 2.9.2
using FUSE kernel interface version 7.19

查看支持的文件系统

[yubo.wang@localhost ~]$ cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   ramfs
nodev   bdev
nodev   proc
nodev   cgroup
nodev   cpuset
nodev   tmpfs
nodev   devtmpfs
nodev   debugfs
nodev   securityfs
nodev   sockfs
nodev   pipefs
nodev   anon_inodefs
nodev   configfs
nodev   devpts
nodev   hugetlbfs
nodev   autofs
nodev   pstore
nodev   mqueue
nodev   selinuxfsxfs
nodev   rpc_pipefs
nodev   nfsdfuseblk
nodev   fuse
nodev   fusectl

ubuntu挂载centos

logread@logread:~$ sshfs root@192.168.201.130:/home/yubo.wang/sshfs-dir /home/logread/sshfs-dir
The authenticity of host '192.168.201.130 (192.168.201.130)' can't be established.
ECDSA key fingerprint is SHA256:cvXKQ2H2nAm+jgN8FjygG/BbubibbHxZridZwoh+FTU.
Are you sure you want to continue connecting (yes/no)? yes
root@192.168.201.130's password:
logread@logread:~$ 

挂载查询

sshfs (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)root@192.168.201.130:/home/yubo.wang/sshfs-dir  116G   99G   18G  85% /home/logread/sshfs-dirsudo umount /home/logread/sshfs-dir

挂载成功,写文件成功

centos挂载ubuntu

挂载测试

[yubo.wang@localhost ~]$ sshfs root@192.168.201.132:/home/logread/sshfs-dir /home/yubo.wang/sshfs-dir
fuse: mountpoint is not empty【目录里面有a.c文件,不为空,难道不能挂载非空目录?】【-o nonempty】
fuse: if you are sure this is safe, use the 'nonempty' mount option[yubo.wang@localhost ~]$ sshfs root@192.168.201.132:/home/logread/sshfs-dir /home/yubo.wang/sshfs-dir
The authenticity of host '192.168.201.132 (192.168.201.132)' can't be established.【不检查key:-o StrictHostKeyChecking=no】
ECDSA key fingerprint is 0c:8d:16:d2:ff:d0:9a:02:0b:f5:ab:92:a9:02:f4:e3.
Are you sure you want to continue connecting (yes/no)? yes
root@192.168.201.132's password:
root@192.168.201.132's password:
root@192.168.201.132's password: 【密码怎么会不对?】
read: Connection reset by peer
[yubo.wang@localhost ~]$ 

难道是ubuntu不支持nfsd?不用root用户改为logread用户挂载成功

[yubo.wang@localhost ~]$ sshfs -o StrictHostKeyChecking=no logread@192.168.201.132:/home/logread/sshfs-dir /home/yubo.wang/sshfs-dir
logread@192.168.201.132's password:
[yubo.wang@localhost ~]$ logread@192.168.201.132:/home/logread/sshfs-dir on /home/yubo.wang/sshfs-dir type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=1002,group_id=1002)logread@192.168.201.132:/home/logread/sshfs-dir   49G   40G  7.1G  85% /home/yubo.wang/sshfs-dir

读写文件成功,卸载成功

fusermount -u /home/yubo.wang/sshfs-dir

卸载Ubuntu的fuse

logread@logread:~$ sudo apt-get remove fuse
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:fuse ntfs-3g sshfs
0 upgraded, 0 newly installed, 3 to remove and 64 not upgraded.
After this operation, 1,620 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 120277 files and directories currently installed.)
Removing ntfs-3g (1:2017.3.23-2ubuntu0.18.04.2) ...
Removing sshfs (2.8-1) ...
Removing fuse (2.9.7-1ubuntu1) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for initramfs-tools (0.130ubuntu3.8) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-96-generic
logread@logread:~$ 

fuse依然存在,sshfs命令消失,说明只卸载了sshfs命令,不能挂载其他设备,但能被挂载

logread@logread:~$ cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   ramfs
nodev   bdev
nodev   proc
nodev   cpuset
nodev   cgroup
nodev   cgroup2
nodev   tmpfs
nodev   devtmpfs
nodev   configfs
nodev   debugfs
nodev   tracefs
nodev   securityfs
nodev   sockfs
nodev   dax
nodev   bpf
nodev   pipefs
nodev   hugetlbfs
nodev   devptsext3ext2ext4squashfsvfat
nodev   ecryptfsfuseblk
nodev   fuse
nodev   fusectl
nodev   pstore
nodev   mqueuebtrfs
nodev   autofs

挂载是否成功:也能挂载,能看到文件

[yubo.wang@localhost ~]$ sshfs -o StrictHostKeyChecking=no logread@192.168.201.132:/home/logread/sshfs-dir /home/yubo.wang/sshfs-dir
logread@192.168.201.132's password:
[yubo.wang@localhost ~]$   

重启ubuntu后也能被挂载。

Linux SSHFS挂载验证-两个虚拟机Linux系统之间相关推荐

  1. Linux SSHFS挂载验证-OpenWRT系统

    开始在Linux板子之间验证sshfs挂载,openwrt系统作为客户端,纯Linux系统(hi3521)作为服务端,下面开始在openwrt系统中搭建sshfs服务. 查看内核支持的文件系统 roo ...

  2. Linux SSHFS挂载验证-海思Linux系统

    在海思Linux系统上搭建sshfs服务端,使用buildroot来编译sshfs工具软件,使用海思的外部编译链,使用动态链接库,由于flash用户空间太小,使用硬盘挂载进行软件和动态库的拷贝软连接安 ...

  3. linux虚拟服务器新增磁盘怎么挂载,如何在vmware虚拟机Linux中增加硬盘的方法(教程)...

    前期准备:创建虚拟硬盘 1.关闭VM中正在运行的虚拟系统: 2.在虚拟系统名称上点右键->Virtual Machine Settings: 3.在Hardware页点"Add&quo ...

  4. Windows向Linux自动传输文件,Windows向虚拟机Linux传输文件方法

    在Windows中装了个centOS,进行文件操作时,把mv写成了rm,然后就悲剧了.. 赶紧从网上找来文件的具体内容,然后由Windows向Linux挂载共享文件夹. 具体做法: 在Windows中 ...

  5. linux如何挂载nfs共享目录,在Linux中,如何挂载NFS共享

    网络文件系统( NFS )是一种分布式文件系统协议,允许你通过网络共享远程目录,使用NFS,可以在系统上挂载远程目录,并像使用本地文件一样使用远程文件. 在Linux和UNIX操作系统上,可以使用mo ...

  6. linux下挂载优盘脚本,一种linux系统下自动挂载U盘的方法与流程

    技术领域 本发明涉及服务器维护技术领域,尤其涉及一种linux系统下自动挂载U盘的方法. 背景技术: 不管是测试服务器的维护,还是用户使用的服务器,在维护.更新.使用过程中,需要使用U盘向服务器拷贝文 ...

  7. linux内核挂载nfs,NFS Client in Linux Kernel - Mount

    几个基本概念 struct nfs_server NFS client parameters stored in the superblock(来自nfs_fs_sb.h的注释). 这是文件系统超级块 ...

  8. linux 两个虚拟机 socket本地,两台虚拟机Linux系统socket通信

    服务器: #include #include #include #include #include #include #include #define SERVER_PORT 20000 // def ...

  9. linux只提取前两个目录名,Linux 文件和目录操作命令(17个)

    文件和目录操作命令(17个) 1ls ls命令的作用是以不同的方式,查看(列出)目录内的内容. [功能说明]:list directory contents [语法格式]:ls [OPTION]... ...

最新文章

  1. SQL Server不能启动
  2. 对抗性攻击的原理简介
  3. CCAI 2020 | 史元春:走出AI伦理困境「演讲回顾」
  4. 最新增值税商品税目编码表_大家好!我叫增值税!这是我的最新最全税率表
  5. Java 8系列之重新认识HashMap(转载自美团点评技术团队)
  6. C语言用递归求斐波那契数,让你发现递归的缺陷和效率瓶颈
  7. Hibernate的单向N-1关联(一)
  8. 以太网和wifi协议
  9. android 手机内存清理,安卓手机内存如何清理 安卓手机内存清理方法【介绍】
  10. 猜数游戏,随机生成一个1~100的数进行猜测。
  11. ca42a_demo_c++_new_delete表达式
  12. 新能源汽车的电池寿命
  13. [免费分享]微信小程序从入门到精通视频教程 [8.2G]
  14. iOS 支持webrtc的浏览器 bowser
  15. Darknet框架解读
  16. md文件如何编辑和转换(不依赖插件Markdown Viewer)
  17. 网站服务器选择什么操作系统,网站服务器选择哪种操作系统比较好
  18. 无线网能连接上但无法连接服务器是啥原因,腾达无线路由器能连接但是上不了网怎么办...
  19. RISC-V基金会董事谭章熹:RISC-V,从边缘逐渐向中央扩展
  20. python 交易日_使用python和tushare股票交易日历数据,判断节假日周末休市

热门文章

  1. 五星级调查公司一览,本页推介,绝对能收到钱,全是优秀调查公司
  2. 剑指Offer JZ45 扑克牌顺子(Java)
  3. DIP-图像增强 (Digital Image Enhancement)
  4. 从零搭建gitlabci环境
  5. Java、模式、美眉、篮球
  6. 单例设计模式(Singleton)附带案例代码仓库
  7. 国内NFT数字藏品平台有哪些值得玩?
  8. TBSSQL 的那些事 | TiDB Hackathon 2018 优秀项目分享
  9. 基于ubuntu的STM32嵌入式软件开发(三)——基于官方标准函数库的软件工程移植
  10. 2位数码管显示00-99的89c51单片机电子秒表设计c语言,2位数码管显示00-99的89c51单片机电子秒表设计 的程序和电路图...