NFS挂载文件夹报错"mount.nfs: No such device"

# 执行挂载命令报错
[root@VM-0-6-centos /]# mount -t nfs 172.16.0.32:/tmp/test /tmp/test06
mount.nfs: No such device

原因分析
在卸载nfs服务的时候我把内核里面的nfs模块一起删掉了,导致重装nfs服务后,服务器不能正常挂载文件

# 查看内核中的nfs模块
[root@VM-0-32-centos tmp]# ll /usr/lib/modules/3.10.0-1160.31.1.el7.x86_64/kernel/fs
total 108
-rw-r--r-- 1 root root 5996 Jun 10  2021 binfmt_misc.ko.xz
drwxr-xr-x 2 root root 4096 Jun 25  2021 btrfs
drwxr-xr-x 2 root root 4096 Jun 25  2021 cachefiles
drwxr-xr-x 2 root root 4096 Jun 25  2021 ceph
drwxr-xr-x 2 root root 4096 Jun 25  2021 cifs
drwxr-xr-x 2 root root 4096 Jun 25  2021 cramfs
drwxr-xr-x 2 root root 4096 Jun 25  2021 dlm
drwxr-xr-x 2 root root 4096 Jun 25  2021 exofs
drwxr-xr-x 2 root root 4096 Jun 25  2021 ext4
drwxr-xr-x 2 root root 4096 Jun 25  2021 fat
drwxr-xr-x 2 root root 4096 Jun 25  2021 fscache
drwxr-xr-x 2 root root 4096 Jun 25  2021 fuse
drwxr-xr-x 2 root root 4096 Jun 25  2021 gfs2
drwxr-xr-x 2 root root 4096 Jun 25  2021 isofs
drwxr-xr-x 2 root root 4096 Jun 25  2021 jbd2
drwxr-xr-x 2 root root 4096 Jun 25  2021 lockd
-rw-r--r-- 1 root root 5224 Jun 10  2021 mbcache.ko.xz
drwxr-xr-x 2 root root 4096 Jun 25  2021 nfs_common
drwxr-xr-x 2 root root 4096 Jun 25  2021 nfsd
drwxr-xr-x 2 root root 4096 Jun 25  2021 nls
drwxr-xr-x 2 root root 4096 Jun 25  2021 overlayfs
drwxr-xr-x 2 root root 4096 Jun 25  2021 pstore
drwxr-xr-x 2 root root 4096 Jun 25  2021 squashfs
drwxr-xr-x 2 root root 4096 Jun 25  2021 udf
drwxr-xr-x 2 root root 4096 Jun 25  2021 xfs

在内核里面我们能看到确实没有nfs这个模块的文件夹了,确实被我删掉了

处理方法

# 1、在其他服务器内核中拷贝nfs文件
scp -rp /usr/lib/modules/3.10.0-1160.31.1.el7.x86_64/kernel/fs/nfs 172.16.0.32:/usr/lib/modules/3.10.0-1160.31.1.el7.x86_64/kernel/fs/

# 2、安装高版本的内核到本服务器,然后从新的内核中拷贝一份到旧的内核中
# 我这里是下载高版本的内核安装
#下载地址:https://pkgs.org/search/?q=kernel
cd /tmp
wget http://mirror.centos.org/centos/7/updates/x86_64/Packages/kernel-devel-3.10.0-1160.36.2.el7.x86_64.rpm

wget http://mirror.centos.org/centos/7/updates/x86_64/Packages/kernel-3.10.0-1160.36.2.el7.x86_64.rpm

 yum localinstall -y kernel-*
 cp -r /usr/lib/modules/3.10.0-1160.36.2.el7.x86_64/kernel/fs/nfs /usr/lib/modules/3.10.0-1160.31.1.el7.x86_64/kernel/fs/

测试

#在客服端测试挂载
[root@VM-0-6-centos fs]# mount -t nfs 172.16.0.32:/tmp/test /tmp/test06

#在服务端测试创建文件
[root@VM-0-32-centos fs]# cd /tmp/test/
[root@VM-0-32-centos test]# ll
total 0
[root@VM-0-32-centos test]# touch test.txt

#在客户端查看新增文件
[root@VM-0-6-centos test06]# ll
total 0
-rw-r--r-- 1 root root 0 Mar  6 13:56 test.txt
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐