add disk tests for virsh

This commit is contained in:
2026-02-06 20:27:45 -05:00
parent 71a27b1b91
commit 837ea91a52
2 changed files with 12 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ Virtual Machine Management
- [Create a Home Assistant VM](#create-a-home-assistant-vm)
- [Snapshots](#snapshots)
- [Creating and Attaching Disks](#creating-and-attaching-disks)
- [Disk Testing and Scripts](#disk-testing-and-scripts)
- [Virt Builder](#virt-builder)
## Before you Begin
@@ -351,9 +352,14 @@ See [qemu qcow2 snapshots](/active/software_qemu/qemu.md#qcow2-snapshots)
To create and attach one disk:
```bash
export VM_NAME="cloud-init-test-fedora"
export VM_DISK_NAME="test1"
qemu-img create -f qcow2 /var/lib/libvirt/images/${VM_DISK_NAME}.qcow2 1G
# QCOW
qemu-img create -f qcow2 /var/lib/libvirt/images/my-disk.qcow2 1G
# Raw (better performance, no snapshots or copy on write)
qemu-img create -f raw /var/lib/libvirt/images/my-disk.raw 1G
# Query disk info (like actual size on disk)
qemu-img info /var/lib/libvirt/images/my-disk.raw
virsh attach-disk ${VM_NAME} \
--source /var/lib/libvirt/images/${VM_DISK_NAME} \
@@ -362,6 +368,8 @@ virsh attach-disk ${VM_NAME} \
--live
```
### Disk Testing and Scripts
To create and attach multiple disks (for raid testing)
```bash