Mount NFS volume in a Proxmox OpenVZ container
Category : How-to
There 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:
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:
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