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:

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

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.

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:

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

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

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


Related posts:


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

Search

Quick Poll

Are you using Docker.io?

Visit our advertisers