Skip to navigationSkip to content
libvirtd docs
Commands

Manual nav

Search `/` or jump with `g` / `G`.

Portal

  • Home manual
  • Command explorer
Foundations6 sections
  • Overview1
  • Installation2
  • Platform1
  • Concepts5
  • Domains2
  • Domain XML2
Subsystems9 sections
  • Identity1
  • Automation2
  • Daemons3
  • virsh3
  • Networking5
  • Storage4
  • Security3
  • Observability2
  • Remote Access1
Operations6 sections
  • Migration2
  • Backup2
  • Performance3
  • Recovery1
  • Troubleshooting2
  • References2

/ search · g top · G quickstart

guidestorageReviewed July 15, 2026

Attach and detach guest disks safely

Device changes have two scopes: the active QEMU process and the persistent domain definition. State the intended scope before issuing the command. Preflight Attach in both scopes Confirm the guest sees the new block devi

attach-diskdetach-diskblocklive

Device changes have two scopes: the active QEMU process and the persistent domain definition. State the intended scope before issuing the command.

Preflight

BASH
virsh domblklist guest01 --details
qemu-img info /var/lib/libvirt/images/data01.qcow2
ls -lZ /var/lib/libvirt/images/data01.qcow2

Attach in both scopes

BASH
virsh attach-disk guest01 /var/lib/libvirt/images/data01.qcow2 vdb \
  --targetbus virtio --driver qemu --subdriver qcow2 --live --config
virsh domblklist guest01 --details

Confirm the guest sees the new block device before creating filesystems or LVM structures.

Detach sequence

Unmount in the guest, stop applications, deactivate guest volume groups if applicable, then detach.

BASH
virsh detach-disk guest01 vdb --live --config
virsh domblklist guest01 --details

Detaching a device is not data deletion. Remove the image only after ownership, retention, and recovery requirements are settled.

Related

  • Safe domain XML editing
  • Daily domain operations with virsh
  • qcow2, raw, and allocation behavior

On this page

  • Preflight
  • Attach in both scopes
  • Detach sequence