Scenario: You have two Ubuntu PCs - you want to share a folder from one to the other. A common answer you’ll see posted around to this is to use Samba. While this does allow the shared folder to be accessed by Windoze machines there is a far simpler and more efficient method that can be used when both machines are Linux.
In the following guide ‘Server’ means the computer where the folder to be shared is (192.168.2.2 in my example) and ‘Client’ (192.168.2.3) is where you would like to access the folder from.
1. Server configuration
1.a - Install required packages:
sudo aptitude -P install nfs-kernel-server nfs-common portmap
1.b - Configure shares. You can do this by editing the file /etc/exports.
sudo vi /etc/exports
In this example I want to share the folder /host on the server with full read and write privileges only allowing access from my local network 192.168.2.1 - 192.168.2.255. I therefore add the line:
/host 192.168.2.1/24(rw,no_root_squash,async)
Save the file and apply your changes with:
sudo exportfs -a
sudo /etc/init.d/nfs-kernel-server restart
That should complete the Server setup. Now on the client(s) where you want to see the directory from:
2. Client Setup
2.a Install nfs-common package
sudo apt-get install nfs-common
2.b Create a mount point (replace host with your chosen mount name).
sudo mkdir /mnt/host
2.c Mount the remote folder
sudo mount 192.168.2.2:/host /mnt/host
That should be it! If this works for you then please digg or leave a comment - thanks!
Happy sharing!




0 Responses to “HOWTO: Set up NFS remote file shariing and mounting in Ubuntu”