File Sharing Between Linux Operating Systems: Mounting with NFS and Samba

In a Linux operating system, how can we mount another system with a Linux operating system? It is essential to ensure that there is a network connection between the two systems, and they are within the same IP block (within the local network). After determining the IP addresses, NFS server must be installed on both servers.

sudo apt install nfs-kernel-server

Once the NFS server is installed, necessary modifications should be made in the /etc/exports file, and the folder to be shared must be defined:

/path/to/source_folder target_ip_address(rw,sync)

While /path/to/source_folder represents the path of the folder to be shared, target_ip_address specifies the IP address of the target system. An NFS client must be installed on the target system:

sudo apt install nfs-common

Next, a folder directory for the file to be mounted should be created:

sudo mkdir /mnt/target_folder

Then, the necessary commands to mount the folder can be executed:

sudo mount target_ip_address:/path/to/source_folder /mnt/target_folder

Here, target_ip_address is where the file will go, /path/to/source_folder represents the path of the shared folder, and /mnt/target_folder specifies the location where the file will be mounted.

After the mount process, you can navigate to the directory where the file is mounted, use the ls command to list the directory, and verify that the file has arrived.

You can perform the same mount process using Samba as follows. First, the installation of Samba is required:

sudo apt install samba

The folder to be mounted is specified as /path/to/source_folder. To edit the file, you can enter the conf file using vi:

sudo vi /etc/samba/smb.conf

A section like [folder_share] should be created in the file, and the following information should be added below it:

path = /path/to/source_folder
writable = yes
guest ok = no

To install Samba on the remote system, the following command is used:

sudo apt install cifs-utils

Then, sharing is done by entering information such as the IP to be sent:

sudo mount -t cifs //source_ip_address/folder_share /mnt/target_folder -o username=user_name,password=password

The username and password parameters specify the username and password for accessing the Samba server. If the mount process is successful, you can view and make changes to the files in the /mnt/target_folder directory using the ls command.

--

--