Mount NFS volume in a Proxmox OpenVZ container

Mount NFS volume in a Proxmox OpenVZ container

Category : How-to

Get Social!

openvz-logo-150px_new_3There are various options for adding additional storage to an OpenVZ container. You can add additional storage to the containers root volume to simply increase the overall storage available to the container. For external storage, or storage on another disk to the root partition of the container there are bind mounts.

With some light work you can also use NFS mounts inside an OpenVZ container. Before NFS will work in a container a command needs to be ran on the host to enable NFS features in the container.

If you do not enable NFS on the container, you will get the following error:

mount: unknown filesystem type 'nfs'

Open a Terminal on the host machine and run the below command to check that the modules are loaded in the kernel:

modprobe nfs

Then run the below command to enable NFS on the container. Make sure container is turned off or restart the container after issuing the command.

vzctl set 998 --features "nfs:on" --save

This writes a change to the containers config file. To avoid using the command, you could simply edit the config file directly and add the below text to the bottom of the file:

FEATURES="nfs:on"

Start the container and make sure that the required packages are installed.

apt-get install nfs-common

If you do not have the required packages installed you may receive the following error

mount: wrong fs type, bad option, bad superblock on 192.168.50.252:/dspool/compressed,
 missing codepage or helper program, or other error
 (for several filesystems (e.g. nfs, cifs) you might
 need a /sbin/mount.<type> helper program)
 In some cases useful info is found in syslog - try
 dmesg | tail or so

Finally, run the mount command to mount your NFS directory.

mount -t nfs 10.10.10.5:/storage/compressed /mnt/testmount


4 Comments

Josh

7-Mar-2014 at 10:08 am

Hey, thanks for the info. One question though, do you know of any way to make this automatic whenever you create a container? I’ll need nfs enabled on any container I ever make so it’d be nice for this feature to always be enabled.

    james.coyle

    7-Mar-2014 at 10:52 am

    Hi Josh,

    Proxmox does not provide this feature for OpenVZ – the attribute is not even changeable in the Proxmox web GUI. You will have to set the attribute on each CT you create.

      Josh

      7-Mar-2014 at 11:19 am

      Thanks for the quick reply! Do you know of any way to hook a script into a container creation to just append that features line to the end of the container config?

        james.coyle

        8-Mar-2014 at 5:40 pm

        Sorry for the slow reply this time!

        I guess you would have to edit the API2 scripts and find the code which creates the container and manually add a write to the CTs config file.

        Have you considered using a bind mount? You mount the NFS on the hardware node and pass it through to each container.
        http://www.jamescoyle.net/how-to/525-proxmox-bind-mount-mount-storage-in-a-container

        Again though, it’s a manual process to create the mount script for each CT.

Leave a Reply

Visit our advertisers

Quick Poll

Do you use ZFS on Linux?

Visit our advertisers