Skip to navigationSkip to content
libvirtd docs
InteractiveCommands

Manual nav

Search `/` · tty `~` · g top · G bottom

Portal

  • Manual index
  • Interactive lab
  • Command explorer
Foundations5 sections
  • libvirtd Overview1
  • Host & Installation2
  • Architecture & Concepts6
  • Domains2
  • Domain XML2
Subsystems6 sections
  • Daemons3
  • virsh3
  • Virtual Networking5
  • Virtual Storage4
  • Virtualization Security3
  • Remote libvirt1
Operations5 sections
  • Migration2
  • Snapshots & Backup2
  • Performance3
  • Troubleshooting2
  • Reference2
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

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

On this page

  • Preflight
  • Attach in both scopes
  • Detach sequence