This article is going to take you through on how to Install NFS Server on Debian 11. NFS(Network File System) is a client/server application that allows a computer user to access, store, and update files on a remote computer. For network attached storage(NAS), NFS is one of several Distributed File System (DFS) standards .
How to Install NFS Server on Debian 11
- Make sure your packages are up to date.
sudo apt update
- Next set a host name.
sudo hostnamectl set-hostname nfs.example.com --static
Install NFS Server
- You can now use the following command to install NFS server after upgrading your packages and setting up your host name.
sudo apt install nfs-kernel-server
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libbotan-2-9 libtspi1 Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: keyutils libnfsidmap2 libtirpc-common libtirpc3 nfs-common rpcbind Suggested packages: open-iscsi watchdog The following NEW packages will be installed: keyutils libnfsidmap2 libtirpc-common libtirpc3 nfs-common nfs-kernel-server rpcbind 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 596 kB of archives. After this operation, 1,846 kB of additional disk space will be used. Do you want to continue? [Y/n] y
- Check the status of NFS, which should be up and running.
sudo systemctl status nfs-server
● nfs-server.service - NFS server and services Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled) Active: active (exited) since Fri 2022-04-15 21:43:04 EAT; 12min ago Process: 3796 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) Process: 3797 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS) Main PID: 3797 (code=exited, status=0/SUCCESS) CPU: 16ms Apr 15 21:43:03 debian systemd: Starting NFS server and services... Apr 15 21:43:04 debian systemd: Finished NFS server and services.
Setup NFS directory share
- We’ll store files that will be shared across the local area network on the NFS directory share. It will be created in the /mnt/directory_name, so let’s create it with the following command.
sudo mkdir /mnt/my_data
- Next, assign ownership and permissions.
sudo chown nobody:nogroup /mnt/my_data sudo chmod -R 777 /mnt/my_data
Configure Exports for client
- Allow client access by editing the exports configuration file. Use the following command to open the exports file.
sudo nano /etc/exports
- Add client that can access the NFS server using the following line in the config file. Note, you can add several lines with different clients IP to add more clients.
Above command meaning;
- rw-Read and Write )
- sync-Write changes to disk before applying them)
- no_subtree_check-Avoid subtree checking )
Then, using the following command, export the shared directory.
sudo exportfs -a
Allow NFS Share Access on Firewall
- Allow NFS with the following command if you’re using a firewall.
sudo ufw allow from 192.168.0.101/24 to any port nfs
- Reload the firewall to apply the changes. By default, NFS runs on port 2049.
sudo ufw reload
- Check status using the command below.
sudo ufw status
Install and Configure NFS Client
- To begin, make sure your client packages are up to date.
sudo apt update
- Use the command below to install the NFS client package.
sudo apt install nfs-common
Mounting NFS Share on the Client
- The following command will create a directory that will be used to mount the NFS share from the NFS server.
sudo mkdir -p /mnt/client_directory
- Mount the remote NFS share directory with the command below after you’ve created the mount directory.
sudo mount SERVER-IP:/mnt/my_data /mnt/client_directory
Test NFS Share
- Navigate to your directory share on the NFS server and create a test file.
cd /mnt/my_data touch nfs_debian.txt
- List the content of the mounted share directory on your client system.
In the client directory, you should be able to see the contents of the server.
- It’s a warp, you have reached the end of the article. You now know how to Install NFS Server on Debian 11.
Read more about NFS commands in the man page
Install and configure Postfix as Send-Only SMTP on Debian 11
Install and Configure Postfix as Send-Only SMTP on Ubuntu 22.04