Attaching external NFS storage

The Generic NFS Reference Driver allows you to mount multiple NFS shares to your compute cluster and use them as external NFS storages.

To attach an external NFS storage

Use the following command:

vinfra service compute storage add <storage_name> --nfs --params nas_host=<nas_ip_address>,nas_share_path=<share_path>
                                   [--nfs-mount-options <options>] --enable

Where:

  • <storage_name> is a custom name of your external storage. The name may only contain letters, numbers, and underscores, and must be 3 to 64 characters long.
  • nas_host=<nas_ip_address> is the IP address of the external storage to connect to.
  • nas_share_path=<share_path> is the root export path of the NFS share.
  • --nfs-mount-options <options> is a comma-separated list of mount options for NFS compute storages, with additional flags separated by spaces. For example: lookupcache=none,nfsvers=4,minorversion=0,timeo=150,retrans=3 -m -s. To see a full list of mount options, refer to the mount and nfs man pages.

    Note that if nfs_shares_config is used, these mount options are applied to every share listed in the configuration file, unless they are overwritten in the configuration file.

    Setting the lookupcache policy to all is not recommended as it leads to issues with accessing volume .info files.

When the --nfs option is specified, it automatically sets the following parameters required for NFS storage:

  • volume_backend_name to the external storage name specified by <storage_name>.
  • volume_driver to the name of the OpenStack volume driver, which is cinder.volume.drivers.nfs.NfsDriver.
  • nfs_mount_options to lookupcache=pos to ensure that the NFS client revalidates negative entries in the directory entry cache.
  • nfs_mount_point_base to the directory to mount the NFS share to, which is /mnt/compute/storages.
  • nas_secure_file_permissions to False to create volumes with open permissions.
  • nfs_qcow2_volumes to True to create volumes as QCOW2 files.
  • nfs_snapshot_support to True and nas_secure_file_operations to False to enable support for snapshots.
  • nfs_sparsed_volumes to True to create volumes as sparsed files, which take no space.

For example, to add the external storage nfs_storage with the IP address 10.10.10.12 and the share path /myshare, run:

# vinfra service compute storage add nfs_storage --nfs --params nas_host=10.10.10.12,nas_share_path=/myshare --enable

Ensure that the data specified is valid. An incorrectly configured storage will lead to the critical state of the cinder-volume service and the node itself. However, all other operations on the node will not be affected.

The added external storage will appear in the vinfra service compute storage list output:

# vinfra service compute storage list
+-------------+----------------------------------------------------+---------------+---------+------------+
| name        | params                                             | secret_params | enabled | configured |
+-------------+----------------------------------------------------+---------------+---------+------------+
| nfs_storage | nas_host: 10.10.10.12                              |               | True    | True       |
|             | nas_secure_file_operations: 'False'                |               |         |            |
|             | nas_secure_file_permissions: 'False'               |               |         |            |
|             | nas_share_path: /myshare                           |               |         |            |
|             | nfs_mount_options: lookupcache=pos                 |               |         |            |
|             | nfs_mount_point_base: /mnt/compute/storages        |               |         |            |
|             | nfs_qcow2_volumes: 'True'                          |               |         |            |
|             | nfs_snapshot_support: 'True'                       |               |         |            |
|             | nfs_sparsed_volumes: 'True'                        |               |         |            |
|             | volume_backend_name: nfs-storage                   |               |         |            |
|             | volume_driver: cinder.volume.drivers.nfs.NfsDriver |               |         |            |
+-------------+----------------------------------------------------+---------------+---------+------------+