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
- 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:/exportnfs2.example.com:/exportEach line must contain an NFS share in the formatHOST:/SHAREwhereHOSTis replaced by the IP address or host name of the NFS server andSHAREis replaced with the particular NFS share to be used. - Use the
chowncommand to set the file to be owned by therootuser and thecindergroup.#chown root:cinderFILEReplaceFILEwith the path to the file containing the list of NFS shares. - Use the
chmodcommand to set the file permissions such that it can be read by members of thecindergroup.#chmod 0640FILEReplaceFILEwith the path to the file containing the list of NFS shares. - Set the value of the
nfs_shares_configconfiguration key to the path of the file containing the list of NFS shares.#openstack-config --set /etc/cinder/cinder.conf \DEFAULT nfs_shares_configFILEReplaceFILEwith the path to the file containing the list of NFS shares. - The
nfs_sparsed_volumesconfiguration key determines whether volumes are created as sparse files and grown as needed or fully allocated up front. The default and recommended value istrue, which ensures volumes are initially created as sparse files.Setting thenfs_sparsed_volumesconfiguration key tofalsewill 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_volumestrue - Optionally, provide any additional NFS mount options required in your environment in the
nfs_mount_optionsconfiguration 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_optionsOPTIONSReplaceOPTIONSwith 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). - Ensure that the correct volume driver for accessing NFS storage is in use by setting the
volume_driverconfiguration key tocinder.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.