❶ cygwin配置了nfs服务,怎样在本地测试nfs服务是否搭建成功
本地环境描述如下: 操作系统:windows 2003 安装cygwin用来虚拟linux环境 配置了cygwin环境的nfs服务,主要是配置了etc目录下面的exports文件,添加nfs共享目录如下: /cygdrive/e/CGEL/test/rootfs (rw, no_root_squash, no_all_squash) 启动了cygwin的nfs服务相关的三个服务:cygwin mountd, cygwin nfsd, cygwin portmap,关闭了系统的防火墙 远程挂载e盘下的CGEL/test/rootfs不成功,不知道问题出在哪里, 是否有本地测试nfs服务是否能用的命令啊? 比如在linux下有 mount -t nfs 192.168.0.1/local/share /mnt/share的命令可以挂载本地的nfs目录试试看能不能用的
(rw, anonuid = 0)mount -t nfs 192.168.0.1:/local/share /mnt/share这里有个冒号 其他跟你一样在我这用的好好的
❷ NFS笔记(二)NFS服务器配置实例
一、NFS服务器配置实例
实验拓扑
二、实验要求及环境
2.1实验环境
NFS服务器 IP:192.168.8.5
环境:
[root@server7 ~]# uname -a
Linux server7.ctos.zu 3.10.0-514.el7.centos.plus.i686 #1 SMP Wed Jan 25 12:55:04 UTC 2017 i686 i686 i386 GNU/Linux
[root@server7 ~]# cat /etc/redhat-release
CentOS release 7.3.1611 (AltArch)
客户端IP:192.168.8.7
环境:
[root@client-A ~]# uname -a
Linux client-A.ctos.zu 2.6.32-696.el6.i686 #1 SMP Tue Mar 21 18:53:30 UTC 2017 i686 i686 i386 GNU/Linux
[root@client-A ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
2.2、实验要求
NFS服务器
1、/home/share 目录可读写,并且不限制用户身份,共享给192.168.8.0/24网段不的所有主机;
2、/home/data 这个目录仅共享给192.168.8.7这台主机,以供该主机上面的这个用户来使用,
也就是说在192.168.8.5和192.168.8.7上均有账号,且账号均为;
3、/home/upload 这个目录做为192.168.8.0/24网段的数据上传目录,其中/home/upload
的用户和所属组为nfs-upload这个名字,它的UID和GID均为222;
4、/home/nfs 这个目录的属性为只读,可提供除了网段内的工作站外,向Internet也提供数据内容。
三、服务器端设置
1、 编辑/etc/exports内容
[root@server7 etc]# cat /etc/exports
/home/share 192.168.8.0/24(rw,no_root_squash)
/home/data 192.168.8.7(rw)
/home/upload 192.168.8.0/24(rw,all_squash,anonuid=222,anongid=222)
/home/nfs 192.168.8.0/24(ro) *(ro,all_squash)
2、按要求建立每个对应目录
2.1、创建/home/share目录 任何人都可以在 /home/share内新增、修改文件,但
仅有该文件/目录的建立者与root能够删除自己的目录或文件。
[root@server7 etc]# mkdir -p /home/share
[root@server7 etc]# ll -d /home/share/
drwxr-xr-x. 2 root root 6 9月 5 15:50 /home/share/
[root@server7 etc]# chmod 1777 /home/share/
[root@server7 etc]# ll -d /home/share/
drwxrwxrwt. 2 root root 6 9月 5 15:50 /home/share/
2.2、创建/home/nfs
[root@server7 etc]# ll -d /home/nfs/
drwxr-xr-x. 2 root root 6 9月 5 16:52 /home/nfs/
2.3、创建/home/data目录
[root@server7 etc]# mkdir -v /home/data
mkdir: 已创建目录 "/home/data"
[root@server7 etc]# ll -d /home/data/
drwxr-xr-x. 2 root root 6 9月 5 16:57 /home/data/
[root@server7 etc]# useradd
root@server7 etc]# passwd
更改用户 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@server7 etc]# cat /etc/passwd | grep
:x:1000:1000::/home/:/bin/bash
[root@server7 etc]# chmod 700 /home/data/
[root@server7 etc]# chown -R : /home/data/
[root@server7 etc]# ll -d /home/data/
drwx------. 2 6 9月 5 16:57 /home/data/
2.4、创建/home/upload目录
#先建立对应账号与组名及UID
[root@server7 etc]# groupadd -g 222 nfs-upload
[root@server7 etc]# useradd -g 222 -u 222 -M nfs-upload
[root@server7 etc]# cat /etc/passwd|grep nfs
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
nfs-upload:x:222:222::/home/nfs-upload:/bin/bash
#创建目录,修改属主
[root@server7 etc]# mkdir /home/upload
[root@server7 etc]# chown -R nfs-upload:nfs-upload /home/upload/
[root@server7 etc]# ll -d /home/upload/
drwxr-xr-x. 2 nfs-upload nfs-upload 6 9月 6 08:38 /home/upload/
2.5、重启NFS服务
[root@server7 etc]# systemctl restart nfs
[root@server7 etc]# systemctl status nfs
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
Active: active (exited) since 三 2017-09-06 08:41:40 CST; 8s ago
Process: 9171 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
Process: 9169 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
Process: 9168 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
Process: 9181 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 9180 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 9181 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
9月 06 08:41:40 server7.ctos.zu systemd[1]: Starting NFS server and services...
9月 06 08:41:40 server7.ctos.zu systemd[1]: Started NFS server and services.
[root@server7 etc]# tail /var/log/messages
Sep 6 08:41:40 server7 systemd: Started NFS Mount Daemon.
Sep 6 08:41:40 server7 rpc.mountd[9178]: Version 1.3.0 starting
Sep 6 08:41:40 server7 systemd: Started NFSv4 ID-name mapping service.
Sep 6 08:41:40 server7 systemd: Starting NFS server and services...
Sep 6 08:41:40 server7 kernel: NFSD: starting 90-second grace period (net c0c932c0)
Sep 6 08:41:40 server7 systemd: Started NFS server and services.
Sep 6 08:41:40 server7 systemd: Starting Notify NFS peers of a restart...
Sep 6 08:41:40 server7 sm-notify[9198]: Version 1.3.0 starting
Sep 6 08:41:40 server7 sm-notify[9198]: Already notifying clients; Exiting!
Sep 6 08:41:40 server7 systemd: Started Notify NFS peers of a restart.
2.6、查看NFS服务器共享出来目录
2.7、关闭防火墙、selinux
2.8查看配置
[root@server7 ~]# exportfs -v
/home/data 192.168.8.7(rw,wdelay,root_squash,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
/home/share 192.168.8.0/24(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
/home/upload 192.168.8.0/24(rw,wdelay,root_squash,all_squash,no_subtree_check,anonuid=222,anongid=222,sec=sys,rw,secure,root_squash,all_squash)
/home/nfs 192.168.8.0/24(ro,wdelay,root_squash,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
/home/nfs <world>(ro,wdelay,root_squash,all_squash,no_subtree_check,sec=sys,ro,secure,root_squash,all_squash)
四、客户端配置
4.1、客户端也要安装nfs-utils和rcpbind软件包
[root@client-A ~]# yum install nfs-utils rpcbind -y
4.2、启动RPC
[root@client-A ~]# service rpcbind start /systemctl start rpcbind
Starting rpcbind: [ OK ]
[root@client-A ~]# service rpcbind status
rpcbind (pid 1926) is running...
[root@client-A ~]# chkconfig --list |grep rpcbind
4.3、客户端关闭防火墙、selinux
[root@client-A ~]# service iptables stop /systemctl stop firewalld
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading moles: [ OK ]
4.4测试网络
[root@client-A ~]# ping 192.168.8.5
PING 192.168.8.5 (192.168.8.5) 56(84) bytes of data.
64 bytes from 192.168.8.5: icmp_seq=1 ttl=64 time=2.16 ms
64 bytes from 192.168.8.5: icmp_seq=2 ttl=64 time=0.697 ms
64 bytes from 192.168.8.5: icmp_seq=3 ttl=64 time=0.346 ms
64 bytes from 192.168.8.5: icmp_seq=4 ttl=64 time=0.336 ms
64 bytes from 192.168.8.5: icmp_seq=5 ttl=64 time=0.335 ms
64 bytes from 192.168.8.5: icmp_seq=6 ttl=64 time=0.317 ms
64 bytes from 192.168.8.5: icmp_seq=7 ttl=64 time=0.512 ms
64 bytes from 192.168.8.5: icmp_seq=8 ttl=64 time=0.320 ms
^C
--- 192.168.8.5 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7555ms
rtt min/avg/max/mdev = 0.317/0.629/2.169/0.595 ms
4.5 在客户端查看NFS服务器共享出来目录
[root@client-A ~]# showmount -e 192.168.8.5
Export list for 192.168.8.5:
/home/nfs (everyone)
/home/upload 192.168.8.0/24
/home/share 192.168.8.0/24
/home/data 192.168.8.7
4.6、挂载NFS服务器上/home/nfs目录到本地/opt/data目录下
#临时挂载
#永久挂载
编辑、/etc/fstab文件,新增如下条目:
192.168.8.5:/home/nfs /opt/data/ nfs4 defaults 0 0
更多信息参考 nfs参数详解
#查看信息
[root@client-A data] # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
6.5G 644M 5.6G 11% /
tmpfs 250M 0 250M 0% /dev/shm
/dev/sda1 477M 26M 426M 6% /boot
192.168.8.5:/home/nfs
8.0G 1.6G 6.5G 20% /opt/data
[root@client-A data]# mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.8.5:/home/nfs on /opt/data type nfs (rw,vers=4,addr=192.168.8.5,clientaddr=192.168.8.7)
#创建文件测试
[root@client-A data]# touch testabc
touch: cannot touch `testabc': Read-only file system
4.7挂载/home/upload 目录到客户端/opt/upload目录下
#挂载
[root@client-A data]# mkdir /opt/upload
[root@client-A data]# mount -t nfs 192.168.8.5:/home/upload /opt/upload/
#查看挂载是否成功
[root@client-A data]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
6.5G 644M 5.6G 11% /
tmpfs 250M 0 250M 0% /dev/shm
/dev/sda1 477M 26M 426M 6% /boot
192.168.8.5:/home/nfs
8.0G 1.6G 6.5G 20% /opt/data
192.168.8.5:/home/upload
8.0G 1.6G 6.5G 20% /opt/upload
#客户端创建nfs-upload用户
[root@client-A ~]# groupadd -g 222 nfs-upload
[root@client-A ~]# useradd -g 222 -u 222 -m nfs-upload
#测试,可以看到创建的文件及目录默认属主为nfs-upload属组为nfs-upload
[@client-A upload]$ pwd
/opt/upload
[@client-A upload]$ ll
total 0
#测试创建文件
[@client-A upload]$ touch test123
测试创建目录
[@client-A upload]$ mkdir testdir
[@client-A upload]$ ll -a
total 4
drwxr-xr-x 3 nfs-upload nfs-upload 36 Sep 6 10:28 .
drwxr-xr-x. 4 root root 4096 Sep 6 18:22 ..
-rw-rw-r-- 1 nfs-upload nfs-upload 0 Sep 6 10:28 test123
drwxrwxr-x 2 nfs-upload nfs-upload 6 Sep 6 10:28 testdir
# 在客户端用root用户创建文件测试
root@client-A upload]# touch testabc
[root@client-A upload]# ll
total 0
-rw-r--r-- 1 root root 0 Sep 6 10:31 nfstest123
-rw-r--r-- 1 nfs-upload nfs-upload 0 Sep 6 10:32 testabc
drwxrwxr-x 2 nfs-upload nfs-upload 6 Sep 6 10:28 testdir
可以看到用root用户创建的文件属主仍是nfs-upload
#测试删除文件
[@client-A upload]$ rm test123
[@client-A upload]$ ll
total 0
drwxrwxr-x 2 nfs-upload nfs-upload 6 Sep 6 10:28 testdir
❸ win10如何用脚本或者命令开启nfs服务时用命令或者脚本
1、点击开始菜单,选中右侧的“控制面板”项;
❹ linux如何知道nfs配置成功,求详细的图解!!!!!!!!!!
以root 身份登陆Linux 服务器,编辑/etc 目录下的共享目录配置文件exports,指定共享目录及权限等。
执行如下命令编辑文件/etc/exports:
# vi /etc/exports
在该文件里添加如下内容:
/home/work 192.168.0.*(rw,sync,no_root_squash)
然后保存退出。
添加的内容表示:允许ip 地址范围在192.168.0.*的计算机以读写的权限来访问/home/work 目录。
/home/work 也称为服务器输出共享目录。
括号内的参数意义描述如下:
rw:读/写权限,只读权限的参数为ro;
sync:数据同步写入内存和硬盘,也可以使用async,此时数据会先暂存于内存中,而不立即写入硬盘。
no_root_squash:NFS 服务器共享目录用户的属性,如果用户是 root,那么对于这个共享目录来说就具有 root 的权限。
接着执行如下命令,启动端口映射:
# /etc/rc.d/init.d/portmap start
最后执行如下命令启动NFS 服务,此时NFS 会激活守护进程,然后就开始监听 Client 端的请求:
# /etc/rc.d/init.d/NFS start
用户也可以重新启动Linux 服务器,自动启动NFS 服务。
在NFS 服务器启动后,还需要检查Linux 服务器的防火墙等设置(一般需要关闭防火墙服务),确保没有屏蔽掉NFS 使用的端口和允许通信的主机,主要是检查Linux 服务器iptables,ipchains 等选项的设置,以及/etc/hosts.deny,/etc/hosts.allow 文件。
我们首先在Linux 服务器上进行NFS 服务器的回环测试,验证共享目录是否能够被访问。在Linux 服务器上运行如下命令:
# mount –t NFS 192.168.0.20:/home/work /mnt
# ls /mnt
命令将Linux 服务器的NFS 输出共享目录挂载到/mnt 目录下,因此,如果NFS 正常工作,应该能够在/mnt 目录看到/home/work 共享目录中的内容。
❺ 如何在Centos 6上设置NFS挂载目录
设置NFS至少需要两台服务器,一台是提供共享文件夹的服务端,一台客户端。
假设服务器和客户端IP地址:
服务器: 192.168.1.100
客户端: 192.168.1.101
一、搭建 NFS 服务端
1、首先使用 yum 安装 NFS 软件。
至此步,即可完成在Centos 6上设置NF挂载目录。
❻ sell 脚本怎么写判断nfs挂载点是否存在
给你想几种办法:
1、文件共享,可采用nfs或rsync之类的方式实现目标主机磁盘可在本地检索或操作,那么你可以通过更改目标主机在本地的映射来操作
2、远程发送指令:这里那就需要目标主机上有相应的服务来监听并应答从远端发出的指令了,expect可以做到通过ssh登陆到目标主机执行相应指令并返回
当然,第二种方式有很多的选择,例如通过http或sokect,但是完全用shell写可能比较难以实现
❼ NFS挂载(ubuntu win10 demoboard)
一:安装 NFS 服务器
sudo apt-get install nfs-kernel-server
二:配置该服务器
sudo vi /etc/exports
在打开的空的文件中,添加想要共享的目录
/srv/share *(rw,sync,no_subtree_squash)
这里: /srv/share 是 ubuntu 给其他平台 ( 开发板,其他远程终端等 ) 提供的共享目录;
* 表示所有客户机都可以挂载上述共享目录,
rw 表示挂接此目录的客户机对该目录有读写的权力,
sync 同步写磁盘
no_root_squash 表示客户端root用户对该目录具备写权限
no_subtree_squash 表示允许挂接此目录的客户机享有该主机的 subtree 身份。
三:启动 NFS 服务
sudo /etc/init.d/nfs-kernel-server start
有同学会出现这个情况:
exportfs :scandir /etc/exports.d no such file or directory
解决办法:sudo mkdir /etc/exports.d
启动NFS服务器成功后会出现:
*Exporting directories for NFS kernel daemon... [OK]
*Starting NFS kernel daemon [OK]
然后,在开发板上做如下设置:
四:打开超级终端或者 DNW ,保持串口处于通信状态
五:通过交叉网线连接 PC 和开发板。这一步千万不能忘, NFS 靠的就是这根线啊,线路都不通了,如何能够配置成功?
六:确保 ubuntu 下的 IP 地址与开发板的 IP 地址在同一网段。二者皆可以通过 ifconfig 查询,以及通过它设置 IP 地址。如果不在同一网段,请手动设置为同一网段。
ifconfig eth0 192.168.149.10
这时,开发板的 IP 就设置成 192.168.149.10 了。
ping一下网络,看是否能ping通。
以上六步已经配置好 NFS 了,下面具体测试是否通信正常:
七:在开发板的 linux 启动后的命令行里输入如下指令:
mount –t nfs –o nolock 192.168.1.103:/srv/share /mnt
其中 192.168.149.7 为 PC 端 ubuntu 的 IP 地址。
前面的挂载命令将会把 PC 端的 ubuntu 下的 /srv/share 目录挂载到开发板的 /mnt 目录。当然,前提是开发板的 linux 系统必须具备这个目录了。
试试先在 ubuntu 的 /srv/share路径放个文件,然后在开发板的命令行终端敲入 ls /mnt ,是不是看到刚才所放的文件了。
八:如果第七步没有成功,请仔细检查以上七步,重复一到七步!
一、安装hane win nfs server,版本1169(官方最新版1223经试验不成功)。
二、设置如下:
三、在-输出->编辑表文件->添加你的目录,选择访问方式和别名->文件-选择保存->退出该软件
d:\nfs_folder -public -name:pc_nfs ip192.168.1.101(ip可加可不加)
四、以管理员身份重启服务(注:软件界面上“重启服务”按钮无效,在安装目录下找到重启服务):
五、若发现还是没有相关的目录出现,重启电脑
六、在开发板的Linux上对nfs目录进行挂载:
1.需将电脑的IP与开发板上的Ip设置在同一网段
2.在embed linux(开发板)输入以下命令:
mount -t nfs -o nolock 192.168.1.103:/pc_nfs_folder /mnt
电脑的IP 目录的别名 开发板上的目录
3.cd 到mnt文件夹下
ls 可以看到pc中该目录对应内容
showmount -e 192.168.1.200
若提示没有showmount这个命令,则安装nfs-common
sudo apt install nfs-common
可以看到在nfs server中挂载的文件夹,如下图所示。
sudo mkdir nfsfolder
挂载文件夹。
mount -e nfs 192.168.1.200:/video /home/nfsfolder
此时,win10和ubuntu即实现了文件夹的共享,win10或ubuntu均可以对该文件夹进行操作。
❽ linux服务器重启了nfs服务,客户端需要重新执行mount挂载吗本来是挂载着的!
理论上应该不需要重新mount,可以把客户端的autofs或者nfs也重启一下
脚本的话可以这样判断
ls-l/mnt/nfsfolder
if[$?-eq0]
then
echonfsisok
else
serviceautofsreload
servicenfsreload
fi
❾ win7使用nfs挂载
1、win7系统中打开命令提示符,确认网络配置没有问题,能ping通对方的IP;
2.可能会遇到没有权限创建目录和文件,解决方法如下:
通过修改注册表将windows访问NFS时的UID和GID改成0即可,步骤如下
1) 在运行中输入regedit,打开注册表编辑器;
2) 进入HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default条目;
3) 选择新建----QWORD64值,新建AnonymousUid,AnonymousGid两个值,值为0.
3、打开控制面板,找到程序找到打开或关闭windows功能;
4、找到NFS服务并勾选安装;
5、回到命令提示符,输入showmount -e +服务器IP地址来确认挂载点;
6、然后用mount命令来挂载,后面那个Z:是分配的盘符
7、这样进到计算机里面就可以看到网络共享目录了。
❿ nfs挂载命令参数、命令文件以及故障案例
(1)mount 命令+参数
(2)进入磁盘的救援模式
变为可以读写模式
mount -o remount,rw /
修改文件
(1)物理服务器
(2)服务端:配置文件的参数
(3)客户端:挂载时mount的一些挂载参数
(4)/etc/sysctl.conf 系统内核配置文件