Virsh attach-disk: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 16: Line 16:


  virsh attach-disk <''vm-name''> <''storage-volume-path''> <''target-device-name''> --config
  virsh attach-disk <''vm-name''> <''storage-volume-path''> <''target-device-name''> --config
A target device name that is available can be obtained by running [[lsblk]] on the virtual machine in question:


  virsh attach-disk testvm-01 /main-storage-pool/test-volume vdb --config
  virsh attach-disk testvm-01 /main-storage-pool/test-volume vdb --config
virsh attach-disk build-guest /main-storage-pool/build-guest-xfs-experiments.raw vdb --config


virsh will detect malformed device names and will error out if that is the case.
virsh will detect malformed device names and will error out if that is the case.

Latest revision as of 18:23, 19 February 2018

Internal

Overview

Examples

Attaching a File-Based Storage Volume

Shut down the guest before attaching the disk. Note that is also possible to add the device while the guest is running, see virsh man page for more details.

Provision the storage volume as described here: virsh vol-create-as.

The command requires at minimum the file-based storage volume path, as shown by the virsh vol-list command, and the device name under which the disk is exposed to guest, typically "vdX", where X is "a", "b", etc.

virsh attach-disk <vm-name> <storage-volume-path> <target-device-name> --config

A target device name that is available can be obtained by running lsblk on the virtual machine in question:

virsh attach-disk testvm-01 /main-storage-pool/test-volume vdb --config
virsh attach-disk build-guest /main-storage-pool/build-guest-xfs-experiments.raw vdb --config

virsh will detect malformed device names and will error out if that is the case.

--config

Will affect the next boot.