Skip to content
Home » Proxmox LXC: Create NFS / CIFS Mount / Mount Folder

Proxmox LXC: Create NFS / CIFS Mount / Mount Folder

The LXC containers in Proxmox are ideal for hosting applications such as Nextcloud, Plex or Paperless-NGX. These services have one thing in common: they access data that is usually stored on a NAS. You do not want to store the data in the LXC itself. This is why NAS shares can be integrated into the LXC container as NFS or CIFS mounts in order to access external data.

Caution!

Privileged LXC containers harbor a not inconsiderable risk. Read more here:

Privileged containers run under the root user of the host system. This means that the root user within the container also has root rights on the host.

Due to the fact that root rights of the container can be extended to the host system, privileged containers pose a higher security risk. A security problem in the container could potentially jeopardize the entire host system.

Proxmox: Mount NFS share in LXC container

NFS or Network File System is a widely used protocol for file transfer on Unix (Linux) systems. NFS shares can be mounted in a privileged Proxmox container with the activated NFS feature.

APT: Install NFS-Common

If the requirements are met, we can install the necessary tools and mount the NFS share. For all common Linux distributions such as: Debian, Ubuntu etc. we need the package NFS Common:

First we update the package sources and the installed packages themselves:

sudo apt-get update && apt-get upgrade -y

For Debian based distributions or all with APT Package Manager:

sudo apt-get install nfs-common

We confirm the query with Yes (Y)

NFS Share Mount

You can then mount an NFS share in the Proxmox LXC container. You can use the mount command for this. Drives mounted using the command are only available until the next reboot. How to mount drives automatically using fstab is described below.

sudo mount -t nfs -o soft 192.168.1.2:/volume1/Cybertalk /mnt/Cybertalk

The mount command follows the following syntax:

mount [parameter] device mount-point

The Mount command followed by the parameters (in this case the type: NFS) is followed by the IP or the host name of the server or the device that provides the NFS share. The local mount point is specified separated by a space. This is the local folder under which we will later find our data on the NFS share storage.

Before you can mount the NFS share you have to create this local folder, otherwise an error message will be returned.

Before we can mount our NFS share on the server 192.168.1.2/volume1/Cybertalk, we must first create the local mount point (folder):

mkdir /mnt/Cybertalk

Then we can attach the mount:

sudo mount -t nfs -o soft 192.168.1.2:/volume1/Cybertalk /mnt/Cybertalk

If we now navigate to our mount point, we can already see the data and folders on the share, if available:

cd /mnt/Cybertalk

ls -a

All files and folders are displayed with ls -a.

Now we want the NFS share to be mounted automatically at every start. To do this, we need to make an entry in the fstab file.

Mount NFS share automatically

The fstab file can be found under /etc/fstab and can be opened with an editor of your choice.

nano /etc/fstab

This is what it looks like:

However, you cannot simply copy the previously created mount command into the fstab file; the syntax is slightly different here. Default stands for the options: rw,suid,dev,exec,auto,nouser,async.

192.168.1.2:/volume1/Cybertalk  /mnt/Medien   nfs   defaults    0 0

Note:

Entries in the individual columns must not contain spaces, as these are interpreted as separators. Spaces in device names, labels or mount points must therefore be enclosed by the character string \040. The backslash is sufficient for other special characters.

Example:

192.168.1.2:/volume1/Cyber talk  /mnt/Medien   nfs   defaults    0 0

The space between Cyber and Talk must be replaced by \040. It will look like this:

192.168.1.2:/volume1/Cyber\040talk  /mnt/Medien   nfs   defaults    0 0

The syntax of the fstab entry for the nfs-mount looks like this:

[device] [mount-point] [filesystem-type] [options] [dump] [pass]

Please note that only one entry per line is written to the fstab file. We now copy our entry into the fstab file under the comment marked with # and save the file with: CTRL + X -> Save Buffer -> Y -> Enter

192.168.1.2:/volume1/Cybertalk  /mnt/Medien   nfs   defaults    0 0

Normally, the “defaults” options are sufficient. If additional options are required for certain applications, this can usually be found in the corresponding documentation.

Even if we have saved the file, the nfs share is not yet mounted. To execute the fstab manually, we need the two commands:

sudo systemctl daemon-reload
sudo mount -a

The NFS share is now mounted in the Proxmox LXC container and available.

Pages: 1 2

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon