KVM High Availability with Shared Storage
Overview
This runbook documents KVM high availability configuration using Synology NAS as shared storage, enabling live VM migration between kvm-01 and kvm-02.
Architecture
Hypervisor Cluster
| Host | Hardware | Resources | Role |
|---|---|---|---|
kvm-01 |
Supermicro A |
16 cores, 64GB RAM |
Primary hypervisor |
kvm-02 |
Supermicro B |
16 cores, 64GB RAM |
Secondary hypervisor |
Phase 1: NAS Configuration
1.1 Create NFS Export on Synology
# SSH to NAS
ssh nas-01
# Create directory structure
sudo mkdir -p /volume1/libvirt/images
sudo chown -R 1000:1000 /volume1/libvirt
Via DSM Web UI:
-
Control Panel → Shared Folder → Create
-
Name:
libvirt -
Location: Volume 1
-
Enable NFS permissions:
-
Hostname:
10.50.1.98(kvm-01),10.50.1.99(kvm-02) -
Privilege: Read/Write
-
Squash: Map root to admin
-
Security: sys
-
Enable async
-
Phase 2: Hypervisor NFS Mount
Phase 4: VM Migration
4.1 Prerequisites
Before migration:
# Verify VM uses NAS storage
sudo virsh domblklist <vm-name> | awk 'NR>2 {print $2}'
# Verify both hypervisors can access the disk
ls -la /mnt/nas/libvirt/<vm-disk>.qcow2
4.2 Live Migration Command
# From source hypervisor (e.g., kvm-01)
sudo virsh migrate --live --persistent --undefine-source \
<vm-name> \
qemu+ssh://root@kvm-02/system
Phase 5: Moving Existing VMs to NAS
For VMs currently on local SSD that should be HA-capable:
5.1 Shutdown VM
sudo virsh shutdown <vm-name>
# Wait for clean shutdown
sudo virsh domstate <vm-name>
5.2 Copy Disk to NAS
sudo rsync -avP /mnt/onboard-ssd/libvirt/images/<vm-name>.qcow2 /mnt/nas/libvirt/
Troubleshooting
NFS Mount Fails
# Check NFS server is reachable
showmount -e 10.50.1.70
# Check firewall on NAS
# DSM → Control Panel → Security → Firewall
# Manual mount test
sudo mount -t nfs4 10.50.1.70:/volume1/libvirt /mnt/nas/libvirt -v
Migration Fails: "Cannot access storage"
Both hypervisors must have identical paths to the storage:
# Verify on both hosts
ls -la /mnt/nas/libvirt/<vm-disk>.qcow2
Quick Reference
| Task | Command |
|---|---|
List NAS pool VMs |
|
Check VM disk location |
|
Live migrate |
|
Migration status |
|
Pool status |
|