nfs网络文件系统

时间:2022-06-01 21:14:56

安装

# apt-get install nfs-kernel-server

配置挂载目录和权限

# vim /etc/exports
/home/rootfs *(rw,sync,no_root_squash)
/home/rootfs 192.168.0.*(rw) *(ro)
/home/rootfs 192.168.0.0/24(rw) *(ro)

*:所有的IP都可以访问
ro:只读
rw:可读写
sync:同步写入硬盘
async:暂存内存
root_squash:root用户访问此目录, 映射成如anonymous用户一样的权限
no_root_squash: root用户访问此目录,具有root操作权限
wdelay:多个用户对共享目录进行写操作时,则按组写入数据
no_wdelay:多个用户对共享目录进行写操作时,则立即写入数据

重启

# /etc/init.d/nfs restart 

exports
修改了/etc/exports后,并不需要重启nfs服务,只要用exportfs重新扫描一次/etc/exports

-a 递增式更新,对/etc/exports 增加或修改的部分进行挂载和卸载
-i<文件> 指定配置文件
-r 更新配置,重新读取/etc/exports
-u 卸载指定目录
-o 使用指定参数
-v 显示共享详细情况
# exportfs -r  //重新配置
# exportfs -au //卸载所有共享目录

启动内核报错

VFS: Unable to mount root fs via NFS, trying floppy
VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
Please append a correct "root=" boot option; here are the available partitions

可能原因:

  1. 网卡驱动没有移植好
  2. NFS服务器配置不正确
  3. 没有安装NFS服务
Kernel panic - not syncing: No init found

NFS文件系统的权限不够