Configure NFS on a Linux server with Cockpit
Cockpit comes from RedHat and is a web front-end for Linux server administration. It works on all RedHat-compatible Linux operating systems, as well as others like Debian, Ubuntu, etc.
One of Cockpit’s best features is its effortless storage UI. With it, users can manage disks, RAIDs, partitions, and even networking filesystems. In this guide, we’ll show you how you can use Cockpit to mount NFS shares.
How to install Cockpit on Linux
Cockpit must be installed on your Linux server before you can use it. Thankfully, it is very easy to set up Cockpit, even on more advanced Linux operating systems. To start, open up a terminal/SSH session with your Linux server. Then, follow the installation instructions that correspond with the Linux OS you use.
Ubuntu installation instructions
To install the Cockpit application on your Ubuntu server, start by running the command below. This command will detect what version of Ubuntu you are using.
. /etc/os-release
After determining your Ubuntu release, you can run the following apt install command to install the Cockpit application on your Ubuntu system. Note that Cockpit will be installed via the “backports” repository, ensuring you’re always up to date with the latest features.
sudo apt install -t ${VERSION_CODENAME}-backports cockpit
Debian installation instructions
If you run a Debian Linux server and wish to install Cockpit on it, you will need to start by validating the version of Debian you are using. You must know the version to get Cockpit to install.
. /etc/os-release
After checking the release, run the following echo command and add the Debian Backports repository to your system. Installing Cockpit via “Backports” ensures you’ll always get Cockpit updates and new features.
echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > \ /etc/apt/sources.list.d/backports.list
Next, run the apt update command to refresh Debian’s software sources.
sudo apt update
Finally, install Cockpit on Debian using the following apt install command.
sudo apt install -t ${VERSION_CODENAME}-backports cockpit
Fedora installation instructions
If you run a Fedora Linux server and wish to install Cockpit, there are no repositories that need to be enabled. Instead, simply run the following dnf install command to set up the software.
sudo dnf install cockpit
Next, enable it using the systemctl command.
sudo systemctl enable --now cockpit.socket
Lastly, add Cockpit to the firewall (if needed).
sudo firewall-cmd --add-service=cockpit sudo firewall-cmd --add-service=cockpit --permanent
RHEL installation instructions
Using RHEL 7? You’ll need to enable the Extras RPMS repo before attempting to set up Cockpit. Enable it with the command below. Those on RHEL 8 will not need to add this repo.
sudo subscription-manager repos --enable rhel-7-server-extras-rpms
You can install Cockpit with the following yum command.
sudo yum install cockpit
Next, enable the Cockpit service.
sudo systemctl enable --now cockpit.socket
Lastly, open up the Firewall for Cockpit.
sudo firewall-cmd --add-service=cockpit sudo firewall-cmd --add-service=cockpit --permanent
CentOS installation instructions
Those on CentOS 7 or later will be able to install Cockpit using yum install.
sudo yum install cockpit
After setting up the Cockpit app on your CentOS system, you will need to enable it and start it using the systemctl command.
sudo systemctl enable --now cockpit.socket
Finally, open up the firewall for Cockpit on CentOS if needed.
sudo firewall-cmd --permanent --zone=public --add-service=cockpit sudo firewall-cmd --reload
How to access Cockpit
Cockpit is accessible via any web browser, so long as it is connected to the same network as the server. To access your Cockpit in the browser, visit the following URL.
https://ip-of-server:9090
If you do not know the local IP address of your server, you can quickly find it with the following command.
hostname -I
How to mount NFS shares using Cockpit
To mount NFS shares using Cockpit, first, ensure you have NFS shares set up. If you do not know how to configure NFS shares, we can help! Follow along with our in-depth NFS setup guide. Then, launch Cockpit, and select “Storage” on the sidebar.
Note: if you do not see “Storage” on the sidebar, you may not have the “Storage” plugin installed already. To get the “Storage” plugin, check the official Cockpit website.
Inside of the “Storage” area of Cockpit, scroll down and locate “NFS mounts.” When you’ve found it, click on the “+” icon. After clicking on the “+” sign, the “New NFS mount” window will appear. Enter the NFS server address in the “Server address box.”
Once you’ve entered the server address, find the “Path on server” box, and click on the drop-down menu. Cockpit will scan the IP address provided for NFS paths. Select the one you wish to mount. Then, enter the local mount point in the “Local mount point” box.
Finally, choose your mount options. To mount at boot, click the “Mount at boot” box. To mount as read-only, click “Mount read-only,” and to enter custom mount options, click the “Custom mount options box.” When you’ve filled out all of your information, click the “Add” button to add the new NFS mount to your server.