Share files over NFS with File Storage on Ubuntu
Introduction
This guide walks you through mounting a File Storage share on Ubuntu Cloud Servers over NFS (Network File System), so that several servers can work with the same files.
Prerequisites
Before starting this guide, you need:
- A File Storage instance with a share, and an access rule that allows your servers. To set them up, see How to get started with File Storage.
- The File Storage's IP address. To find it, see How to get started with File Storage.
- Basic understanding of Linux command line to work with files
File Storage & NFS basics
File Storage is UpCloud's managed network storage service that provides shared storage accessible over your SDN Private Networks. It's ideal for:
- Shared application data across multiple servers
- Centralized file storage for web applications
- Storing backups and logs
- Content management systems requiring shared media storage
NFS (Network File System) is a distributed file system protocol that allows you to mount remote directories on your server. It enables multiple servers to access the same files simultaneously, making it perfect for use with File Storage.
Creating the client server
Now create an Ubuntu server that will access the File Storage:
- In the Control Panel, navigate to Servers → Deploy server
- Configure your server:
- Location: Select the same location as your File Storage
- Plan: Select a server plan based on your needs
- Operating system: Choose Ubuntu 24.04 LTS or later
- Under Network, select Attach private network
- Select the SDN Private Network that your File Storage is attached to
- Pick or create an SSH key
- Hostname: Give it a descriptive name (e.g., "nfs-client-01")
Wait for the server to be provisioned and start. Once it's running, connect to it via SSH using the configured SSH key.
Install NFS client on Ubuntu
Connect to your Ubuntu server via SSH and install the NFS client packages:
sudo apt update
sudo apt install nfs-common -yThe nfs-common package provides the necessary tools to mount NFS shares on Ubuntu.
Mount the File Storage share
Create a mount point
First, create a directory where the File Storage will be mounted:
sudo mkdir -p /mnt/sharedMount the NFS share
Mount the share using the File Storage IP address and the share path. Replace FILE_STORAGE_IP with the actual IP address from your File Storage instance:
sudo mount -t nfs FILE_STORAGE_IP:/data /mnt/sharedFor example, if your File Storage IP is 192.168.0.100:
sudo mount -t nfs 192.168.0.100:/data /mnt/sharedVerify the mount:
df -h | grep /mnt/sharedYou should see output showing the mounted File Storage with its total size and available space.
Make the mount persistent
To ensure the File Storage is automatically mounted after server reboots, add an entry to /etc/fstab. Add the following line at the end of the file (replace FILE_STORAGE_IP with your actual IP):
FILE_STORAGE_IP:/data /mnt/shared nfs defaults,_netdev,vers=4.1,nconnect=8,rsize=1048576,wsize=1048576,noatime,hard 0 0The _netdev option ensures the system waits for network connectivity before attempting to mount the share. The mount options have been optimized for best performance.
Test the fstab entry:
sudo umount /mnt/shared
sudo mount /mnt/sharedVerify the mount is successful:
df -h | grep /mnt/sharedTest the File Storage
Now test that you can read and write to the File Storage:
Create a test file
echo "Hello from File Storage!" > /mnt/shared/test.txtRead the test file
cat /mnt/shared/test.txtYou should see the output: Hello from File Storage!
Test from multiple servers
To demonstrate the shared nature of File Storage:
- Create another Ubuntu Cloud Server following the same steps
- Attach it to the same SDN Private Network
- Install the NFS client and mount the same File Storage share
- You'll be able to see the same files on both servers
- Changes made on one server are immediately visible on the other
Performance considerations
The fstab entry in this guide uses the mount options we recommend for File Storage shares. For what each option does, see How to get started with File Storage.
Troubleshooting
Mounting fails
- Verify your server is attached to the correct SDN Private Network
- Check that the File Storage instance is reachable:
ping FILE_STORAGE_IP - Ensure your firewall rules allow NFS traffic (TCP port 2049)
- Check the share's access rights in the Control Panel
- Verify your server's SDN Private Network IP is allowed in the share configuration
Mount becomes unresponsive
- Check network connectivity to the File Storage:
ping FILE_STORAGE_IP - Verify the File Storage instance is running in the Control Panel
- Check system logs for errors:
sudo journalctl -xe | grep nfs