如何在Linux和Windows中挂载NFS共享?

Network File System or NFS is a network-based filesystem protocol which is mainly used to share files and folders over the network. NFS is a UNIX based technology but can be used by most of the operating systems like Linux, Ubuntu, Debian, Kali, Mint, Fedora, CentOS, RedHat and Windows operating systems Windows 7, Windows 8, Windows 10, Windows Server 2008, Windows Server 2012, Windows Server 2016.

网络文件系统或NFS是基于网络的文件系统协议,主要用于通过网络共享文件和文件夹。 NFS是一种基于UNIX的技术,但可以用于大多数操作系统,例如Linux,Ubuntu,Debian,Kali,Mint,Fedora,CentOS,RedHat和Windows操作系统Windows 7,Windows 8,Windows 10,Windows Server 2008,Windows Server 2012,Windows Server 2016。

安装NFS服务器 (Install NFS Server)

NFS packages mainly divided into two parts. First is the server side packages which will install related kernel modules and server tools.

NFS软件包主要分为两个部分。 首先是服务器端软件包,它将安装相关的内核模块和服务器工具。

Ubuntu,Debian,Mint,Kali客户端软件包 (Ubuntu, Debian, Mint, Kali Client Packages)

$ sudo apt-get install nfs-common

Fedora,CentOS,Fedora客户端软件包 (Fedora, CentOS, Fedora Client Packages)

$ sudo yum install nfs-utils

Ubuntu,Debian,Mint,Kali服务器软件包 (Ubuntu, Debian, Mint, Kali Server Packages)

$ sudo apt-get install nfs-kernel-server
Ubuntu, Debian, Mint, Kali Server Packages
Ubuntu, Debian, Mint, Kali Server Packages
Ubuntu,Debian,Mint,Kali服务器软件包

After the installation is complete the nfs-server service will be also created automatically.

安装完成后,还将自动创建nfs-server服务。

Fedora,CentOS,Fedora服务器软件包 (Fedora, CentOS, Fedora Server Packages)

$ sudo yum install nfs-utils

检查NFS服务状态 (Check NFS Service Status)

As the NFS shares will be served over nfs-server we need to the if it is working. We will use systemctl status command with the nfs-server service name.

由于NFS共享将通过nfs-server我们需要对其进行检查。 我们将使用systemctl status命令和nfs-server服务名称。

$ sudo systemctl status nfs-server
Check NfS Service Status
Check NfS Service Status
检查NfS服务状态

We can see that the service is active and working properly.

我们可以看到该服务处于活动状态并且可以正常工作。

启动NFS服务 (Start NFS Service)

If the service is not started or stopped in any way we need to start the nfs-server service. We will use systemctl start command with the nfs-server service name like below.

如果未以任何方式启动或停止该服务,则需要启动nfs-server服务。 我们将使用systemctl start命令和nfs-server服务名称,如下所示。

$ sudo systemctl start nfs-server

创建NFS共享 (Create NFS Share)

NFS main configuration is stored in the /etc/exports file. Each share is created line by line. For example, if we want to share /mnt with the IP address 192.168.10.10  we will use the following configuration.

NFS的主要配置存储在/etc/exports文件中。 每个共享都是逐行创建的。 例如,如果我们要共享IP地址为192.168.10.10的/mnt ,我们将使用以下配置。

/mnt     192.168.10.10

But generally, we share the files and folders with everyone who has access to the NFS server. We can use the following configuration to share everyone.

但通常,我们与有权访问NFS服务器的每个人共享文件和文件夹。 我们可以使用以下配置共享所有人。

/mnt     *

启用导出 (Enable Exports)

After creating the share configuration we need to refresh the NFS table where the shares are stored. We can simply use exportfs command with the -a option which will add current configuration to the NFS table.

创建共享配置后,我们需要刷新存储共享的NFS表。 我们可以简单地将exportfs命令与-a选项一起使用,这会将当前配置添加到NFS表中。

$ sudo exportfs -a

挂载Linux的NFS共享 (Mount NFS Share For Linux)

We can use mount command in order to mount NFS share. We will specify the filesystem type as nfs to the mount command with the -t option like below. The server IP address is 192.168.142.144 and share is /mnt . We will mount to the /home/ismail/poftut1.

我们可以使用mount命令来挂载NFS共享。 我们将使用-t选项将文件系统类型指定为mount命令的nfs,如下所示。 服务器IP地址为192.168.142.144 ,共享为/mnt 。 我们将挂载到/home/ismail/poftut1

$ sudo mount -t nfs 192.168.142.144:/mnt /home/ismail/poftut1/

列出NFS挂载 (List NFS Mounts)

After mounting the NFS share we can check it by listing the NFS mount. We will use mount command and filter NFS shares with the grep command like below.

挂载NFS共享后,我们可以通过列出NFS挂载进行检查。 我们将使用mount命令,并使用grep命令过滤NFS共享,如下所示。

$ mount | grep nfs
List NFS Mounts
List NFS Mounts
列出NFS挂载

卸载Linux的NFS共享(Unmount NFS Share For Linux)

We can unmount already mounted NFS shares with the umount command. We will just specify the mount path to the umount command with the sudo  command like below.

我们可以使用umount命令卸载已经挂载的NFS共享。 我们将只使用sudo命令指定umount命令的安装路径,如下所示。

$ sudo umount /home/ismail/poftut1

挂载Windows的NFS共享 (Mount NFS Share For Windows)

First, we will enable NFS modules or features on Windows operating systems. Open Start > Control Panel > Programs. Select Turn Windows Features on or off. Select Services for NFS. Click OK.

首先,我们将在Windows操作系统上启用NFS模块或功能。 打开开始>控制面板>程序。 选择“打开或关闭Windows功能” 。 选择NFS服务。 单击确定

LEARN MORE  How To Map Network Drive In Windows?
了解更多信息如何在Windows中映射网络驱动器?

We can mount NFS shares in Windows operating systems too. We will use mount command. We will also provide nolock option and other parameters like remote NFS server IP address and local drive which is Z in this case.

我们也可以在Windows操作系统中挂载NFS共享。 我们将使用mount命令。 我们还将提供nolock选项和其他参数,例如远程NFS服务器IP地址和本地驱动器(在这种情况下为Z

> mount -o nolock 192.168.142.144:/mnt z:

Alternatively, we can use net use command which can also mount NFS shares. We will provide the partition name which is z and remote NFS server.

另外,我们可以使用net use命令来挂载NFS共享。 我们将提供分区名称z和远程NFS服务器。

> net use z: \\192.168.142.144\mnt

翻译自: https://www.poftut.com/how-to-mount-nfs-share-in-linux-and-windows/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值