How to Set Up a NFS Server on Debian 10 Buster

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.

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.

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.

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.

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.

How to Set Up a NFS Server on Debian 10 Buster的更多相关文章

  1. nfs server的配置 Starting NFS daemon: [FAILED]

    总结了一下是nfs server的制作过程:nfs(Network File System)其实就是说,这个机器的硬盘不够了,我要把文件放到别的服务器上去,服务器端的配置如下:首先(1)确保你的机器上 ...

  2. nfs:server 172.168.1.22 not responding,still trying问题解决方法 平台为RealARM 210平台

    nfs:server 172.168.1.22 not responding,still trying问题解决方法 ,平台为RealARM 210平台. 这里的问题是在使用nfs挂载文件系统时遇到的, ...

  3. windows nfs server for linux

    摘要 在开发嵌入式系统的过程中,为了方便调试与文件共享,需要使用到nfs,即网络文件系统,这位板子的调试测试带来了很大的方便.之前在linux系统下开发,与ARM11核心板 linux系统对接共享也比 ...

  4. Ubuntu 12.04安装NFS server

    首先安装nfs-kernel-server apt-get install nfs-kernel-server 然后创建一个目录: mkdir -p /opt/share 并赋予权限777: chmo ...

  5. nfs:server is not responding,still trying 原因与解决

    方案(学自他人) nfs:server is not responding,still trying的解决方法 (2009-04-20 10:20) 方法1 : 我在arm上通过NFS共享文件时出现下 ...

  6. Linux 文件服务---------- nfs Server

    Linux 文件服务nfs (Network file system)#网络文件系统 ---> 远程文件调用samba #文件共享(unix /linux /windows ) ,只能适用于局域 ...

  7. 树莓派 nfs server安装

    安装服务 sudo  apt-get install  portmap sudo  apt-get install  nfs-kernel-server 配置: sudo nano /etc/expo ...

  8. CentOS 7下NFS Server作rootfs时的兼容性问题

    最近新装CentOS 7,发现原先CentOS 6.3下可用的一块ARM Dev board不能用了,表现为VFS mount挂载rootfs失败. 使用WireShark发现,服务器对client发 ...

  9. NFS Server宕机后,NFS Client主机上df命令挂死

    方法1: 使用root用户:Oracle@NDMCDB05:~> su -Password: NDMCDB05:~ # cat /etc/mtab /dev/sda2 / reiserfs rw ...

随机推荐

  1. STM32之SPI时钟相位选择

    SPI的时钟模式分为四种,由SPI_CR1寄存器的两位CPOL,CPHA组合选择. CPOL 如果为1,则时钟的空闲电平为高电平:CPOL 如果为0,则时钟的空闲电平为低电平.空闲电平影响不大. CP ...

  2. 09 单例设计模式、__new__函数

    设计模式 设计模式是前任工作的总结和提炼,通常,被人们广泛流传的设计模式都是针对某一特定问题的成熟的解决方案. 使用设计模式是为了可重用代码.让代码更容易的被他人理解.保证代码的可靠性. 单例设计模式 ...

  3. Qt:用 __thread 关键字让每个线程有自己的全局变量

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/wsj18808050/article/d ...

  4. Golang高阶:Golang1.5到Golang1.12包管理

    Golang1.5到Golang1.12包管理 1. 前言 Golang 是一门到如今有十年的静态高级语言了,2009年的时候算是正式推出了,然后到最近的一两年,2017-2018年的时候,突然直线上 ...

  5. map函数的应用

    map函数在Python中的应用 函数介绍: map() 会根据提供的函数对指定序列做映射. map(function, iterable, ...) 第一个参数function 以参数序列中的每一个 ...

  6. jqTransform:呈现更美的表单

    jqTransform,是DFC Engineering写的一个jQuery的样式插件,用于美化表单元素,使用方便简单,能美化所有表单元素包括input,radio,textarea,select,c ...

  7. 安卓开发之利用runOnUiThread在子线程更新UI

    package com.lidaochen.test; import android.graphics.Bitmap; import android.graphics.BitmapFactory; i ...

  8. 碰撞器Colider 触发器

    碰撞器可以让所依附的游戏物件对其他碰撞体产生碰撞行为(其他游戏物体必须具有Rigidbody组件) 对于不规则形状的物体,通常使用组合式碰撞体而不是网格碰撞器,以为网格碰撞器以模型的网格为基础,更为复 ...

  9. Linux命令——procinfo

    简介 proc文件系统是一个虚拟文件系统,包含有关进程和系统信息的文件. proc 文件系统开机时自动挂载并映射到/proc目录.许多程序从/proc目录中检索信息,对其进行处理并使其易于用于各种目的 ...

  10. Linux命令——logger

    参考:How to use logger on Linux Difference between /var/log/messages, /var/log/syslog, and /var/log/ke ...