Posts Tagged ‘alex’

How to Install and Set Up an NFS Server network Shares on on Linux to easify data transfer across multiple hosts

Monday, April 7th, 2025

How to Configure NFS Server in Redhat,CentOS,RHEL,Debian,Ubuntu and Oracle Linux

Network File System (NFS) is a protocol that allows one system to share directories and files with others over a network. It's commonly used in Linux environments for file sharing between systems. In this guide, we'll walk you through the steps to install and set up an NFS server on a Linux system.

Prerequisites

Before you start, make sure you have:

  • A Linux system distros (e.g., Ubuntu, CentOS, Debian, etc.)
  • Root or sudo privileges on the system.
  • A network connection between the server (NFS server) and clients (machines that will access the shared directories).
     

1. Install NFS Server Package

 

On Ubuntu / Debian based Linux systems:

a. First, update the package list 

# apt update

b. Install the NFS server package
 

# apt install nfs-kernel-server

On CentOS/REL-based systems:

 2. Install the NFS server package
 

      # yum install nfs-utils 

Once the package is installed, ensure that the necessary services are enabled.

 3. Create Shared Directory for file sharing

Decide which directory you want to share over NFS. If the directory doesn't exist, you can create one. For example:

# mkdir -p /nfs_srv_dir/nfs_share

Make sure the directory has the appropriate permissions so that the nfs clients can access it.

# chown nobody:nogroup /nfs_srv_dir/nfs_share 
# chmod 755 /nfs_srv_dir/nfs_share

4. Configure NFS Exports ( /etc/exports file)

The NFS exports file (/etc/exports) is perhaps most important file you will have to create and deal with regularly to define the expored shares, this file contains the configuration settings for directories you want to share with other systems.

       a. Open the /etc/exports file for editing:

vi /etc/exports

Add an entry for the directory you want to share. For example, if you're sharing /nfs_srv_dir/nfs_share and allowing access to all systems on the network (192.168.1.0/24), add the following line:
 

/nfs_srv_dir/nfs_share 192.168.1.0/24(rw,sync,no_subtree_check)


Here’s what each option means:

  • rw: Read and write access.
  • sync: Ensures that changes are written to disk before responding to the client.

 

Here is few lines of  example of my working /etc/exports on my home running NFS server

/var/www 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/home/jordan 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/mnt/sda1/icons-frescoes/ 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/home/mobfiles 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/mnt/sda1/icons-frescoes/ 192.168.0.200/32(rw,no_root_squash,async,subtree_check)
/home/hipo/public_html 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/home/alex/public_html 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/home/necroleak/public_html 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/bashscripts 192.168.0.209/32(rw,no_root_squash,async,subtree_check)
/backups/Family-Videos 192.168.0.200/32(ro,no_root_squash,async,subtree_check)

 

5. Export the NFS Shares with exportfs command

Once the export file is configured, you need to inform the NFS server to start sharing the directory:
 

# exportfs -a


The -a flag will make it export all the sharings.

6. Start and Enable NFS Services

You need to start and enable the NFS server so it will run on system boot.

On Ubuntu / Debian Linux run the following commands:
 

# systemctl start nfs-kernel-server 
# systemctl enable nfs-kernel-server


On CentOS / RHEL Linux:
 

# systemctl start nfs-server
# systemctl enable nfs-server


7. Allow NFS Traffic Through the Firewall

If your server has a firewall configured / enabled, you will need to allow NFS-related ports through the firewall.
These ports include 2049 TCP protocol Ports (NFS) and 111 (RPCbind) UDP and TCP protocol , and some additional ports.

On Ubuntu/Debian (assuming you are using ufw [UNCOMPLICATED FIREWALL]):

# ufw allow from 192.168.1.0/24 to any port nfs sudo ufw reload

On CentOS / RHEL Linux:

# firewall-cmd –permanent –add-service=nfs sudo firewall-cmd –permanent –add-service=mountd sudo firewall-cmd –permanent –add-service=rpc-bind sudo firewall-cmd –reload

8. Verify NFS Server is Running

To ensure the NFS server is running properly, use the following command:
 

# systemctl status nfs-kernel-server

or

# systemctl status nfs-server

You should see output indicating that the service is active and running.

 

9. Test the NFS Share (Client-Side)

To test the NFS share, you will need to mount it on a client machine. Here's how to mount it:

On the client machine, install the NFS client utilities:

Ubuntu / Debian Linux

# apt install nfs-common

For CentOS / RHEL Linux

# yum install nfs-utils


Create a mount point (Nomatter the distro),:
 

# mkdir -p /mnt/nfs_share


Mount the NFS share:

# mount -t nfs <nfs_server_ip>:/nfs_srv_dir/nfs_share /mnt/nfs_share

Replace <nfs_server_ip> with the IP address of the NFS server or DNS host alias if you have one defined in /etc/hosts file.

Verify that the share is mounted:

​# df -h

You should see the NFS share listed under the mounted file systems.

10. Configure Auto-Mount at Boot (Optional)

To have the NFS share automatically mounted at boot, you can add an entry to the /etc/fstab file on the client machine.

Open /etc/fstab for editing:

# vi /etc/fstab

Add the following line: 

<server-ip>:/nfs_srv_dir/nfs_share /mnt/nfs_share nfs defaults 0 0

Save and close the file.

The NFS share will now be automatically mounted whenever the system reboots.

Debug NFS configuration issues (basics)

 

You can continue to modify the /etc/exports file to share more directories or set specific access restrictions depending on your needs.

If you encounter any issues, checking the server logs or using
 

# exportfs -v
/var/www          192.168.0.209/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/home/var_data      192.168.0.205/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/mnt/sda1/
        192.168.0.209/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/mnt/sda2/info
        192.168.0.200/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/home/mobfiles    192.168.0.209/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/home/var_data/public_html
        192.168.0.209/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/var/public
        192.168.0.209/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/neon/data
        192.168.0.209/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/scripts      192.168.0.209/32(async,wdelay,hide,sec=sys,rw,secure,no_root_squash,no_all_squash)
/backups/data-limited
        192.168.0.200/32(async,wdelay,hide,sec=sys,ro,secure,no_root_squash,no_all_squash)
/disk/filetransfer
        192.168.0.200/23(async,wdelay,hide,sec=sys,ro,secure,no_root_squash,no_all_squash)
/public_shared/data
        192.168.0.200/23(async,wdelay,hide,sec=sys,ro,secure,no_root_squash,no_all_squash)


 Of course there is much more to be said on that you can for example, check /var/log/messages /var/log/syslog and other logs that can give you hints about issues, as well as manually try to mount / unmount a NFS stuck share to know more on what is going on, but for a starter that should be enough.

command can help severely in troubleshooting the NFS configuration.

Sum it up what learned ?

We learned how to  set up basic NFS server and mounted its shared directory on a client machine.
This is a great solution for centralized file sharing and collaboration on Linux systems (even though many companies are trying to not use it due to its lack of connection encryption for historical reasons NFS has been widely used over the years and has helped dramatically for the Internet as we know it to become the World Wide Web of today. Thus for a well secured network and perhaps not a critical files infrastructure, still NFS is a key player in file sharing among heterogenous networks for multitudes of Gigabytes or Terra Pentabytes of data you would like to share amoung your Personal Computers / Servers / Phones / Tablets and generally all kind of digital computer equipment devices.

Life going nowhere …

Sunday, September 23rd, 2007

Meaningless_life-picture

Seems, My life is going nowhere. Today I drinked half of a bottle of Wine and 1 beer. I was out with Alex. We drinked in the city park. Through the day I started my first bsd jail using a tutorial online. I smoked a lot of cigarettes and I want to stop them again. Most of the people I met are not a good company for me that's what I'm thinking more and more. Also I'm thinking more and more I have to change my living place. If only I could find the love of my life … We moved bookshelf and stuff from our room ( My mother again has decided to make repairs in our room. ). I'm asking myself why shall I live a meaningless life. At least my interest into computers and computing started to appear again (this is cool). My faith is really going away since I pray and pray for something .. and I don't receive it ( Or at least I don't see it). I'm tired of waiting. I need to have this physical healing to continue my normal life. I'm not proud of me I was a little aggressive when we was in the Mino's coffee before an hour or so … Now I intend to watch another episode of stargate SG1. And to go to the DreamLand. If only I could live into a Dreamland all the time. I'm starting to realize I should change the music I listen, I should change a lot of my behaviours If I want to have a new and happy life. Autumn is a beautiful Season 🙂 The autumn rain shall come and restore us :)END—–

Wine in The Central Park

Friday, January 11th, 2008

I and Alex Drunk Asenovgrad’s Mavrut in the central park it was very cold, but at least an experience. Right now I’m a little hot (cause of the wine). I’m urinating too often recently and it drives me mad. Also I’m a kind of lost I told Sasho about Torsion fields and stuff but he make a fun of that no matter I think that’s a serious matter here is an interview with Nikolay Palushev that may be of an interest to the reader
http://www.spiralata.net/kratko/articles.php?lng=bg&pg=128 .

Today I had English in the college pretty boring haven’t had a lot of work I had to fix few binary permissions part of a postfix also delete some old backups and create a new samba share some mail server problems for few minutes I think that’s all … I hate this world so much everything is so useless and awful. I hope to meet God soon …

What’s going around Lately

Saturday, April 19th, 2008

Nothing special. Last week went just fine thanks to the Lord ! Of Course :). It was mostly peaceful. What was interesting was a method our teacher at management choose to use to make us better understand ourselves. She said I want all of you to draw me a picture of how do you foresee yourself ten years from now :). We all was surprised but just as she requested we did draw the pictures. My picture had 4 possibly futures. In one of them I was with my wife and a kid in front of our house, on the other I was owning and leading an IT company. On one of them I was helping to get out of the terrible pit of depression, addiction to drug, alcoholism, telling them “Stop there is a reason to live, God Loves you!”. In the other case I was a Senior SysAdmin in a middle size/big company managing servers/clusters. Now we had to make a report explaining our picture. I just did make my report hope the teacher would like it. Yesterday, Bino came home and proposed to go out, we went out we saw Stoyan (who btw is a Brother in Christ). Later we saw Dancho a friend of mine (a communist). First we started a normal talk later the talk just transformed into a terrible and useless argue I did a mistake not stopping whenever I had to. And in the end we decided not to see each other because it’s bad for both of us. Later Alex (an ex class-mate) called me and we went we had a walk in the central park and talked ’bout if I can say it like this “the life, the universe, and everything else” :). The next few weeks outline to be a tough one. We are going to have a lot of exams 8 or 9 ! We had a lot of projects and assignments but still I trust on the Holy one to help me make all of them and do just fine on the exams just like he helped me the last semester and the previous year.END—–

Opera!

Saturday, May 10th, 2008

Yesterday I and Alex went to an Opera. We watched Opera by Giuseppe Verdi called “La Traviata”.It’s the second time I see this opera, the first time was when I was still a puppil.Pretty awesome opera the actors were really good. And this classic music! Awesome!After the Opera performance I phoned to Ivo a.k.a. (Order)we went to a sort of pub which wasextremely cheap considering the fact it was near the center and the food and drinks were really good.After all this we had a walk around in Varna and hitted the road back to Dobrich.Kimmo My finish colleague is leaving for Finland and was organizing farewell party.Unfortunately because of the Opera I was unable to go to the party. Yesterday was a really niceday considering that nice opera show. The bad news for me yesterday was that I didn’t passedthe written exam in German and I have to go to the re-sit at Tuesday. With the Lord’s helpI hope I would pass it 🙂 Also I’m going to start for the Accounting exam because It’s at Monday.END—–

Death Metal singing animals :)

Monday, February 20th, 2012

Alex, just passed me by few funny videos, with "animals singing death metal"

Death Metal Singing Rooster

This Rooster, should definitely contact Six Feet Under (SFU) 's vocalist – Chris Barnes for a solo album 😉

I guess this Camel should start innovative metal music fork to Grind Core or Noise Core metal genre sub-division 🙂


I'm sure you never imagined the donkey could be an awesome Metal singer, Well believe it or not it is a fact the donkey has a talent 🙂


This dog is quite experienced in Death Metal vocalist stage behaviour 😉

There is plenty of other Metal singing animals in Youtube, for more laugh check the related videos. Enjoy ! 🙂

How to convert UTF-8 encoding files to Windows CP1251 on GNU / Linux

Friday, October 21st, 2011

I needed to convert a file which had a Bulgarian text written in UTF-8 encoding to Windows CP1251 in order to fix a website encoding problems after a move of the website from one physical server to another.

I tried first with enca( detects and convert encoding of text files from one encoding to another).

The exact way I tried to convert was:

linux:~# enca -L bg /home/site/www/includes/utf8_encoded_file.php
...
Unfortunately this attempt to conver was unsucesfully, and the second logical guess was to use iconvConvert encoding of given files from one encoding to another to do the utf8 to cp1251 conversion.
I reached for some help in irc.freenode.net, #varnalab channel and Alex Kuklin helped me, giving me an example command line to do the conversion.
iconv winedows to cp1251 conversion line, he pointed to me was:

linux:~# iconv -f utf8 -t cp1251 < in > out

Further on I adapted Alex’s example to convert my utf8_encoded_file.php encoded Bulgarian characted to CP1251 and used the following commands to convert and create backups of my original UTF8 file:

linux:~# cd /home/site/www/includes
linux:/home/site/www/includes# iconv -f utf8 -t cp1251 < utf8_encoded_file.php in > utf8_encoded_file.php.cp1251
linux:/home/site/www/includes# mv utf8_encoded_file.php utf8_encoded_file.php.bak
linux:/home/site/www/includes# mv utf8_encoded_file.php.cp1251 utf8_encoded_file.php