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

由于在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 1500
        inet 192.168.201.132  netmask 255.255.255.0  broadcast 192.168.201.255
        inet6 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 0
        TX 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	devpts
	ext3
	ext2
	ext4
	squashfs
	vfat
nodev	ecryptfs
	fuseblk
nodev	fuse
nodev	fusectl
nodev	pstore
nodev	mqueue
	btrfs
nodev	autofs

CentOS 7.3

查看IP地址

[yubo.wang@localhost ~]$ ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.201.130  netmask 255.255.255.0  broadcast 192.168.201.255
        inet6 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 0
        TX 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 Resolution

Dependencies Resolved

===================================================================================
 Package              Arch             Version                Repository      Size
===================================================================================
Installing:
 fuse-sshfs           x86_64           2.10-1.el7             epel            50 k

Transaction Summary
===================================================================================
Install  1 Package

Total 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 transaction
  Installing : 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	selinuxfs
		xfs
nodev	rpc_pipefs
nodev	nfsd
		fuseblk
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-dir

sudo 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	devpts
	ext3
	ext2
	ext4
	squashfs
	vfat
nodev	ecryptfs
	fuseblk
nodev	fuse	
nodev	fusectl
nodev	pstore
nodev	mqueue
	btrfs
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后也能被挂载。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
centos 挂载ntfs所需要的步骤 我就是在挂载2TB的时候发现的 linux挂载NTFS分区移动硬盘2010-09-23 16:35CentOS 挂载NTFS分区移动硬盘 1.uname -r 查看当前的linux内核版本. [root@localhost Desktop]# uname -r 2.6.18-128.el5 2.去http://www.linux-ntfs.org/下载与内核版本相同的ntfs补丁.具体的地址 3.安装补丁:kernel-module-ntfs-2.6.18-128.el5-2.1.27-0.rr.10.11.i686.rpm [root@localhost Desktop]# rpm -ivh kernel-module-ntfs-2.6.18-128.el5-2.1.27-0.rr.10.11.i686.rpm Preparing... ########################################### [100%] 1:kernel-module-ntfs-2.6.########################################### [100%] 4.使用fdisk -l查看硬盘的分区信息. 5.mkdir /mnt/xxx 在mnt文件夹里新建文件夹,分别对应于移动硬盘下的分区(xxx为文文件夹名) 如:mkdir /mnt/name1 对应于叫做name1的盘 6.mount -t ntfs /dev/sdyz /mnt/xxx 将移动硬盘下的各分区挂载在新建的文件夹里(sdyz为硬盘的分区号码) 如: [root@localhost Desktop]# mount -t ntfs /dev/sdc1 /mnt/TheLORD,OurGod 今天将USB移动硬盘挂在CentOS上准备将压缩包拷贝下来的。 结果挂载移动硬盘的时候却提示: mount: unknown filesystem type ‘ntfs’ 原因:Linux无法识别NTFS格式的分区。 解决: 因为刚刚将CentOS升级到了2.6.18-164.el5内核,无法使用Kernel NTFS Module挂载Windows下的NTFS分区(没有在开源站点上找到相应内核包),所以只有使用ntfs-3g来解决了。 打开ntfs-3g的下载站点,将最新稳定版(当前最新版本为ntfs-3g-2010.3.6)下载到CentOS,执行以下命令安装: 1、编译安装ntfs-3g: #./configure #make #make install [/code] 2、查看USB设备点: #fdisk -l Disk /dev/sdb: 60.0 GB, 60011642880 bytes 255 heads, 63 sectors/track, 7296 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 * 1 653 5245191 b W95 FAT32 /dev/sdb2 654 7295 53351865 f W95 Ext'd (LBA) /dev/sdb5 654 1958 10482381 b W95 FAT32 /dev/sdb6 1959 7295 42869421 7 HPFS/NTFS 3、挂载NTFS分区: #mount -t ntfs-3g /dev/sdb6 /mnt/win

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值