由于在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. MultipartEntity与UrlEncodedFormEntity区别
  2. Sam Hartman 当选 Debian 社区领导人
  3. C语言显示字符型和整型数据类型的表示范围
  4. reactjs定义组件:函数式组件
  5. Boole‘s,Doob‘s inequality,中心极限定理Central Limit Theorem,Kolmogorov extension theorem, Lebesgue‘s domin
  6. 实现深拷贝的几种方法
  7. HDU 5680 zxa and set 水题
  8. CodeForces 230A
  9. C# 委托?这篇文章让你困惑全摆脱!
  10. linux重启openfire服务,Centos下Openfire详细安装过程
  11. 记录免费的学习资源-视频教程
  12. 高数特殊符号-希腊字母
  13. ant组件中select默认选中某一项
  14. 谷歌语法和FOFA常用语法总结
  15. 鸡小德手机小常识 如何鉴定手机是否为行货
  16. 华硕PRIME Z390-P主板设置开启虚拟化技术
  17. 《JS实现复制内容到剪贴板功能,可兼容所有PC浏览器,不兼容手机端》
  18. 【转载】面向对象编程的弊端是什么?
  19. Educational Codeforces Round 96 (Rated for Div. 2) ABCD
  20. C++实现简易的画图软件

热门文章

  1. 小红书如何打造优质的商品笔记?
  2. 2021华为杯数学建模D题解题-抗乳腺癌候选药物的优化建模
  3. 【原创】通过Web远程浏览并控制Mini6410上的摄像头(二)
  4. 怎样做ppt如何用PPT绘制卫星轨迹图形表达?
  5. 校园铃声系统 v6.2 官方
  6. html网易云音乐地址播放代码,请求到了网易云歌曲到在线地址,如何在web页面中播放?...
  7. 实验吧CTF逆向题目Just Click题解
  8. python-----DataFrame.style (三、切片)
  9. 苹果手机怎么定时开关机_苹果手机授权内存满了导致开不了机怎么办
  10. 360杀毒属于计算机操作系统吗,买来的盗版XP操作系统光盘被360杀毒检出有木马怎么办?...