Again, just a quick note to remind myself how to attach a disk to a VM guest from the command line.

The following steps is based on these assumptions:

  • A spare disk: an LVM volume name db2_data on data volume group
  • The name/domain of the VM is db2

List the name of the VM guest and available logical volume.

[root@mathvm5 ~]# virsh list | grep db2
 20    db2                            running
[root@mathvm5 ~]# lvs | grep db2
  db2                     vm  -wi-ao----  80.00g
  db2_data                vm  -wi-a----- 128.00g

Run virsh attach-disk command to attach a disk to a VM. Notice that –persistent option is passed to the command so that this new disk will be permanently attached to the VM.

[root@mathvm5 ~]# virsh attach-disk --domain db2 /dev/mapper/vm-db2_data \
> --target vdb --persistent --config --live
Disk attached successfully

Verify on the db2 server:

[root@db2 lib]# udisksctl status
MODEL                     REVISION  SERIAL               DEVICE
--------------------------------------------------------------------------
VirtIO Disk                                              vda
QEMU DVD-ROM              1.5.      QM00001              sr0
VirtIO Disk                                              vdb

Read more: