文档章节

How to Set Up a NFS Server on Debian 10 Buster

o
 osc_aq3v6w0z
发布于 2019/11/28 11:28
字数 1006
阅读 15
收藏 1

「深度学习福利」大神带你进阶工程师,立即查看>>>

Nick Congleton
Debian
24 May 2019
 

There are plenty of reasons why you'd want to share files across computers on your network, and Debian makes a perfect file server, whether you're running it from a workstation, dedicated server, or even a Raspberry Pi. Since NFS functionality comes from the kernel, everything is fairly simple to set up and well integrated.

In this tutorial you will learn:
  • How to Install the NFS Packages
  • How to Configure Your Shares
  • How to Connect to a Share
NFS Share on Debian 10
NFS Share on Debian 10.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Debian 10 Buster
Software NFS Server
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Install the NFS Packages

Install NFS on Debian 10
Install NFS on Debian 10.

NFS is super simple to install on Debian. It's connected to the kernel, and it's a common package. You can install everything you need from the main repositories.

$ sudo apt install nfs-kernel-server

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.



Configure Your Shares

Start by creating a directory that you want to share or choosing an existing one. Make sure that the directory that you choose doesn't have root-only permissions.

NFS Exports on Debian 10
NFS Exports on Debian 10.

Next, open up /etc/exports with your favorite text editor. This is the file that you'll use to set up your shares. Here, you can configure which directories you're sharing and who can access them. You can also set specific permissions for the shares to further limit access.

In the file, each share gets its own line. That line begins with the location of the share on the server machine. Across from that, you can list the hostname of an accepted client, if is available in the server's hosts file, or an IP or range of IPs. Directly behind the IP address, place the rules for the share in a set of parenthesis. Altogether, it should look something like this:

/media/nfs		192.168.1.0/24(rw,sync,no_subtree_check)



You can include as many shares as you like, provided each has its own line. You can also include more than one hostname or IP in each line and assign them different permissions. For example:

/media/nfs		192.168.1.112(rw,sync,no_subtree_check) 192.168.1.121(ro,sync,no_subtree_check)

In that instance, each of those machines could view and read from the share, but only the computer at 192.168.1.112 could write to it.

There are plenty more options that you can choose from to configure how the server handles you share for each guest. Here is a complete breakdown of what's available:

  • ro: specifies that the directory may only be mounted as read only
  • rw: grants both read and write permissions on the directory
  • no_root_squash: is an extremely dangerous option that allows remote “root” users the same privilege as the “root” user of the host machine
  • subtree_check: specifies that, in the case of a directory is exported instead of an entire filesystem, the host should verify the location of files and directories on the host filesystem
  • no_subtree_check: specifies that the host should not check the location of the files being accessed withing the host filesystem
  • sync: this just ensures that the host keeps any changes uploaded to the shared directory in sync
  • async: ignores synchronization checks in favor of increased speed

Once you have everything set up the way you want, save and exit the file. Then, restart the server to load your new exports configuration.

$ sudo systemctl restart nfs-kernel-server

Connect to a Share

Your share is now accessible from the client machines that you configured in your exports. Assuming that your clients are Ubuntu or Debian based, you can install the required package to connect with:

$ sudo apt install nfs-common
NFS Share Mounted on Debian 10
NFS Share Mounted on Debian 10.

With that, you'll be able to mount the NFS shares. So, to try it out, pick a directory to mount to, and run the mount command as root privileges to mount the networked share.

$ sudo mount -t nfs4 192.168.1.110:/media/nfs /media/share



Provided the mount succeeded, you'll be able to access your shared files in the directory where you mounted them.

For a more permanent solution, you can add the share to your client's /etc/fstab file. The overall syntax looks a lot like the command that you just used to mount your share. Start with the location of the share on your network. Follow that with where the share is to be mounted. The filesystem type here is nfs4. The options are up to you, but using the defaults and allowing user access are pretty common for non-sensitive shares. The end result should look a bit like the example below.

192.168.1.110:/media/nfs	/media/share	nfs4	defaults,user,exec	0 0

If you aren't certain if the share will always be available on the client, add noauto to the list of options to prevent your system from trying to mount it automatically.

192.168.1.110:/media/nfs	/media/share	nfs4	defaults,user,exec,noauto	0 0

Try mounting it on the client using /etc/fstab.

$ sudo mount -a

Your share should be mounted exactly where you specified.

Conclusion

Your Debian server is now ready to start serving files, and you shouldn't have any trouble setting up the rest of your client machines. Remember that NFS doesn't have much in the way of security, so you're going to need other methods to restrict access to your files, should you choose to share anything more sensitive.

o
粉丝 0
博文 500
码字总数 0
作品 0
私信 提问
加载中
请先登录后再评论。
记一次失败的Perl + Nginx + FastCGI 配置过程

这两天心血来潮,不知道为什么和 Perl + Nginx + FastCGI 配置 耗上了。但是失败了,记录如下: 1)安装Nginx 1.4.3 ,我的是WINDOWS 7 系统,修改配置文件如下: location ~ .(pl|cgi|perl)?...

通吃岛-低手哥
2013/10/27
1.8K
7
树莓派(Raspberry Pi):完美的家用服务器

自从树莓派发布后,所有在互联网上的网站为此激动人心的设备提供了很多有趣和具有挑战性的使用方法。虽然这些想法都很棒,但树莓派( RPi )最明显却又是最不吸引人的用处是:创建你的完美家用...

异次元
2013/11/09
8K
8
opm-server-mirror

代码更新 2009-11-25: 加入反爬虫功能。直接Web访问服务器将跳转到Google。 使用方法 下载index.zip 解压index.zip得到index.php 将index.php传到支持php和cURL的国外服务器上 打开 http:/...

luosheng86
2013/01/29
1K
0
集群存储系统--YFS

YFS集群存储系统由多个元数据服务器(MDS)、多个块数据服务器(CDS)和多个客户端(client)互联组成集群; 数据被分成64M固定大小的数据块(Chunk),每个数据块在CDS本地以常规文件的形式...

匿名
2013/02/19
1.8K
0
DNS服务器软件--BIND 10

BIND 10 是下一代的 Bind 。 Bind是一款开放源码的DNS服务器软件,Bind由美国加州大学Berkeley分校开发和维护的,全名为Berkeley Internet Name Domain它是目前世界上使用最为广泛的DNS服务器...

匿名
2013/02/22
3.7K
1

没有更多内容

加载失败,请刷新页面

加载更多

汇总你在 Linux 上的命令使用情况

使用合适的命令,你可以快速了解 Linux 系统上使用的命令以及执行的频率。 汇总 Linux 系统上使用的命令只需一串相对简单的命令以及几条管道将它们绑定在一起。当你的历史记录缓冲区保留了最...

osc_bvincwvq
17分钟前
7
0
Hacker News 简讯 2020-08-15

最后更新时间: 2020-08-15 07:01 Welders set off Beirut blast while securing explosives - (maritime-executive.com) 焊工在固定炸药的同时引爆了贝鲁特爆炸 得分:383 | 评论:322 Factor......

FalconChen
今天
24
0
OSChina 周六乱弹 —— 老椅小猫秋乡梦 梦里石台堆小鱼

Osc乱弹歌单(2020)请戳(这里) 【今日歌曲】 @小小编辑 :《MOM》- 蜡笔小心 《MOM》- 蜡笔小心 手机党少年们想听歌,请使劲儿戳(这里) @狄工 :腾讯又在裁员了,35岁以上清退,抖音看到...

小小编辑
今天
111
3
构建高性能队列,你不得不知道的底层知识!

前言 本文收录于专辑:http://dwz.win/HjK,点击解锁更多数据结构与算法的知识。 你好,我是彤哥。 上一节,我们一起学习了如何将递归改写为非递归,其中,用到的数据结构主要是栈。 栈和队列...

彤哥读源码
今天
17
0
Anaconda下安装keras和tensorflow

Anaconda下安装keras和tensorflow 一、下载并安装Anaconda: Anaconda下载 安装步骤: 如果是多用户操作系统选择All Users,单用户选择Just Me 选择合适的安装路径 然后勾选这个,自动配置环境...

Atlantis-Brook
今天
15
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部