Show Table of Contents
4.3. Shared Storage Example: NFS for a Simple Migration
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
syncparameter 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.
Create a directory for the disk imagesThis 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
Add the new directory path to the NFS configuration fileThe 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]
- Make sure that the ports for NFS in
iptables(2049, for example) are opened and add NFS to the
- Start the NFS service:
# service nfs start
Mount the shared storage on both the source and the destinationMount the
/var/lib/libvirt/imagesdirectory on both the source and destination system, running the following command twice. Once on the source system and again on the destination system.
WarningMake 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.