Data Disks
macOS VMs: the playbooks in this document do not apply to macOS guests. macOS disks sit on q35’s built-in SATA controller (not hotpluggable, and no virtio-blk driver), and macOS guests have no Python for Ansible. The data disk is instead created automatically at VM-create time from the
data_disk_gbcolumn (see macOS VMs); each playbook detectstype=macosand aborts with adiskutilpointer.
Attach Data Disk
Reads data_disk_gb from vms.csv. The VM must have data_disk_gb > 0 defined in CSV. Hot-plugs the disk to the running VM using virsh attach-disk --config --live (persistent + immediate effect).
Inside the VM, format and mount the new disk:
Resize Data Disk
Reads target data_disk_gb from vms.csv. The playbook will:
- Check if target size is larger than current (shrinking not supported)
- If VM is running → graceful shutdown and wait for stop
- Resize qcow2 file with
qemu-img resize - If VM was running → automatically start VM again
After resize, expand the filesystem inside the VM:
Note: If VM is already shut off, the playbook resizes the disk directly without auto-starting it.
Mount Disk
Format and mount data disk inside Linux VM. Requires the VM to be defined in hosts.ini.
Parameters
disk_device: disk device path (default:/dev/vdb)mount_point: mount point (required, e.g./data)disk_format: filesystem type (default:ext4)need_partition: create GPT partition (default:false, raw disk mount)format_force: force reformat (default:false)auto_mount: add to fstab (default:true)
Examples
The playbook will:
- Install
partedif needed - Create GPT partition table (if
need_partition=true) - Format disk with specified filesystem
- Add fstab entry with UUID
- Mount and verify
Tags: -t partition, -t format, -t mount (run specific steps only)
Extra Disks (add / list / delete)
Add as many extra virtio-blk disks as needed at runtime, independent of the
data_disk_gb column (which stays reserved for the single disk
create-vm.yaml builds). Disks are named <vm>-extra<N>.qcow2 in the VM’s
storage dir; both the next free index and the next free host target (vdX)
are auto-detected from live and persistent config, so repeated runs never
collide.
Linux guests only: virtio-blk hot-plug works on a running VM
(--config --live, visible immediately, no reboot); a shut-off VM gets
the disk via --config only, visible on next boot.
Add
List
Shows each disk’s index, virtual size, and its target in the live domain and/or persistent config:
Delete
Detaches the disk (live + config on a running VM — virtio-blk hot-unplug)
and deletes the qcow2 file. Destroys data, so confirm=true is required:
Identifying a disk inside the guest
The guest kernel assigns its own vdX names, which usually differ from the
host target. Each extra disk carries a serial <vm>-extra<N> — match on it:
Format/mount afterwards with mount-disk.yaml (pass the guest device
name, e.g. -e disk_device=/dev/vdc).