Managing KVM Virtual Environments via Command Line Tools on Linux

To define a storage pool of type 'dir', specify the target path using the last argmuent, and fill the remaining parameters with dashes.

virsh pool-define-as Spool1 dir - - - - "/mnt/personal-data/SPool1/"

KVM1

View Defined Storage Pools

List all storage pools in the environment using:

virsh pool-list --all

KVM2

Build the Storage Pool

Construct the previously defined storage pool with the following command:

virsh pool-build Spool1

KVM3

Activate and Start the Pool

Start and activate the newly created and built storage pool using:

virsh pool-start Spool1

KVM4

Check Pool Status

Verify the status of the storage pool with:

virsh pool-list --all

KVM5

The Spool1 should now show as active.

Enable Auto-start

Configure the pool to start automatically with libvirtd:

virsh pool-autostart Spool1

KVM6

Review Pool Details

Examine the updated pool information:

virsh pool-info Spool1

KVM7

The Spool1 is now ready for use. Proceed to create storage volumes.

Step Two: Configure Storage Volumes/Disk Images

Create disk images within the Spool1 using the qemu-img command. Refer to the manual for more details:

man qemu-img

Create a Storage Volume

Specify operations like "create", "check", etc., image format, path, and size after qemu-img:

qemu-img create -f raw /mnt/personal-data/SPool1/SVol1.img 10G

KVM8 KVM8_1

Inspect Volume Information

Use qemu-img info to retrieve details about the new disk image:

KVM9

Warning: Do not modify images currently used by running virtual machines or other processes, as this can corrupt the image.

Step Three: Create a Virtual Machine

Create VM

Use virt-install to create a new KVM virtual machine. This tool interfaces with the libvirt libray. See the manual for more information:

man virt-install

To create a new KVM guest, execute the command with necessary parameters including:

  • Name
  • Memory allocation
  • CPU configuration
  • Disk image location
  • Network settings
  • Installation source (ISO, PXE, etc.)

Example:

virt-install \
  --name test-vm \
  --memory 2048 \
  --vcpus 2 \
  --disk path=/mnt/personal-data/SPool1/SVol1.img,format=raw \
  --graphics vnc,listen=0.0.0.0 \
  --network bridge=virbr0 \
  --os-type linux \
  --os-variant ubuntu20.04 \
  --cdrom /path/to/ubuntu.iso

This setup creates a virtual machine with specified resources and an attached disk.

Tags: Linux KVM virtualization command-line libvirt

Posted on Fri, 23 Oct 2026 16:41:13 +0000 by vombomin