8.4.3. Configuring for NFS Storage Backend

This procedure documents the steps involved in configuring the volume service to use NFS storage. The NFS shares to be used must already exist and be accessible from the server hosting the volume service.
All steps listed in this procedure must be performed while logged into the system hosting the volume service as the root user.

Important

To access instance volumes on NFS shares, SELinux requires the virt_use_nfs Boolean enabled on any client machine accessing the instance volumes. This includes all compute nodes. Run the following command on each client machine as the root user to enable the Boolean and make it persistent across reboots:
# setsebool -P virt_use_nfs on
  1. Create a text file in the /etc/cinder/ directory containing a list of the NFS shares that the volume service is to use for backing storage.
    nfs1.example.com:/export
    nfs2.example.com:/export
    Each line must contain an NFS share in the format HOST:/SHARE where HOST is replaced by the IP address or host name of the NFS server and SHARE is replaced with the particular NFS share to be used.
  2. Use the chown command to set the file to be owned by the root user and the cinder group.
    # chown root:cinder FILE
    Replace FILE with the path to the file containing the list of NFS shares.
  3. Use the chmod command to set the file permissions such that it can be read by members of the cinder group.
    # chmod 0640 FILE
    Replace FILE with the path to the file containing the list of NFS shares.
  4. Set the value of the nfs_shares_config configuration key to the path of the file containing the list of NFS shares.
    # openstack-config --set /etc/cinder/cinder.conf \
       DEFAULT nfs_shares_config FILE
    Replace FILE with the path to the file containing the list of NFS shares.
  5. The nfs_sparsed_volumes configuration key determines whether volumes are created as sparse files and grown as needed or fully allocated up front. The default and recommended value is true, which ensures volumes are initially created as sparse files.
    Setting the nfs_sparsed_volumes configuration key to false will result in volumes being fully allocated at the time of creation. This leads to increased delays in volume creation.
    # openstack-config --set /etc/cinder/cinder.conf \
       DEFAULT nfs_sparsed_volumes true
  6. Optionally, provide any additional NFS mount options required in your environment in the nfs_mount_options configuration key. If your NFS shares do not require any additional mount options or you are unsure then skip this step.
    # openstack-config --set /etc/cinder/cinder.conf \
       DEFAULT nfs_mount_options OPTIONS
    Replace OPTIONS with the mount options to be used when accessing NFS shares. See the manual page for NFS for more information on available mount options (man nfs).
  7. Ensure that the correct volume driver for accessing NFS storage is in use by setting the volume_driver configuration key to cinder.volume.drivers.nfs.NfsDriver.
    # openstack-config --set /etc/cinder/cinder.conf \
    DEFAULT volume_driver cinder.volume.drivers.nfs.NfsDriver
The volume service has been configured to use NFS storage.