Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

4.3. Shared Storage Example: NFS for a Simple Migration

Important

This example uses NFS to share guest virtual machine images with other KVM host physical machines. Although not practical for large installations, it is presented to demonstrate migration techniques only. Do not use this example for migrating or running more than a few guest virtual machines. In addition, it is required that the sync parameter is enabled. This is required for proper export of the NFS storage. In addition, it is strongly recommended that the NFS is mounted on source host physical machine, and the guest virtual machine's image needs to be created on the NFS mounted directory located on source host physical machine. It should also be noted that NFS file locking must not be used as it is not supported in KVM.
iSCSI storage is a better choice for large deployments. Refer to Section 12.5, “iSCSI-based Storage Pools” for configuration details.
Also note, that the instructions provided in this section are not meant to replace the detailed instructions found in Red Hat Linux Storage Administration Guide. Refer to this guide for information on configuring NFS, opening IP tables, and configuring the firewall.
  1. Create a directory for the disk images

    This shared directory will contain the disk images for the guest virtual machines. To do this create a directory in a location different from /var/lib/libvirt/images. For example:
    # mkdir /var/lib/libvirt-img/images
  2. Add the new directory path to the NFS configuration file

    The NFS configuration file is a text file located in /etc/exports. Open the file and edit it adding the path to the new file you created in step 1.
    # echo "/var/lib/libvirt-img/images" >> /etc/exports/[NFS-Config-FILENAME.txt]
  3. Start NFS

    1. Make sure that the ports for NFS in iptables (2049, for example) are opened and add NFS to the /etc/hosts.allow file.
    2. Start the NFS service:
      # service nfs start
  4. Mount the shared storage on both the source and the destination

    Mount the /var/lib/libvirt/images directory on both the source and destination system, running the following command twice. Once on the source system and again on the destination system.
    # mount source_host:/var/lib/libvirt-img/images /var/lib/libvirt/images

    Warning

    Make sure that the directories you create in this procedure is compliant with the requirements as outlined in Section 4.1, “Live Migration Requirements”. In addition, the directory may need to be labeled with the correct SELinux label. For more information consult the NFS chapter in the Red Hat Enterprise Linux Storage Administration Guide.