LinuxCommandLibrary

qm-create

Create new virtual machines (VMs)

TLDR

Create a virtual machine with access to 512MiB of memory and 1 CPU core

$ qm [[cr|create]] [100]
copy

Give the virtual machine a name and automatically start the machine after creation
$ qm [[cr|create]] [100] --name [vm_name] --start
copy

Give a virtual machine specified amount of memory and CPUs
$ qm [[cr|create]] [100] --memory [8192] --cores [4]
copy

Specify the type of operating system on the machine
$ qm [[cr|create]] [100] --ostype [win10]
copy

Replace an existing machine (requires archiving it)
$ qm [[cr|create]] [100] --archive [path/to/backup_file.tar] --force 1
copy

Specify a script that is executed automatically depending on the state of the virtual machine
$ qm [[cr|create]] [100] --hookscript [path/to/script.pl]
copy

Specify the install media
$ qm [[cr|create]] [100] --cdrom [local:iso/install-media.iso]
copy

Create a VM that bridges itself to the host network
$ qm [[cr|create]] [100] --net[0] virtio,bridge=vmbr[0]
copy

SYNOPSIS

qm create [OPTIONS]

PARAMETERS


    The unique ID for the new virtual machine (100-999999999).

--name
    Sets the VM's descriptive name.

--ostype
    Specifies the guest operating system type (e.g., l26 for Linux, win10 for Windows).

--memory
    Sets the amount of RAM in MiB allocated to the VM.

--cores
    Defines the number of CPU cores.

--cpu
    Selects the CPU type (e.g., host for host CPU features, kvm64).

--net
    Configures a network device (e.g., virtio,bridge=vmbr0).

--scsi
    Defines a SCSI disk device (e.g., storage:size=32G).

--ide
    Defines an IDE disk device.

--sata
    Defines a SATA disk device.

--virtio
    Defines a VirtIO block device.

--bootdisk
    Specifies which disk to boot from (e.g., scsi0, ide0).

--boot
    Sets the boot order for devices (e.g., cdn for CD-ROM, Disk, Network).

--template
    Marks this VM as a template, preventing it from being started directly.

--description
    Adds a textual description or note for the VM.

--onboot
    Determines if the VM should start automatically when the host boots (0=no, 1=yes).

--agent
    Enables or disables the QEMU guest agent (0=disabled, 1=enabled).

--bios
    Specifies the BIOS type (e.g., seabios, ovmf for UEFI).

--vga
    Sets the virtual graphics adapter type (e.g., std, qxl).

--ciuser
    Cloud-init: Sets the default username for cloud-init.

--sshkeys
    Cloud-init: Provides SSH public keys for the default user.

DESCRIPTION

The qm-create command is a fundamental utility within the Proxmox Virtual Environment (PVE) for provisioning new KVM (Kernel-based Virtual Machine) instances from the command line. It enables administrators to define the essential configuration parameters for a VM, including its unique virtual ID (VMID), allocated memory, CPU resources, network interfaces, and storage devices. This command is crucial for setting up a VM's infrastructure before an operating system is installed or disk images are imported. It integrates seamlessly with Proxmox's diverse storage backends (such as LVM, ZFS, directory, or Ceph) and network configurations (like virtual bridges), allowing for flexible and powerful VM deployments. While qm-create sets up the VM's hardware configuration, it does not install an operating system; that typically follows via ISO installation or cloud-init. For a comprehensive list of all available options, users should consult the official Proxmox VE documentation or use qm create --help.

CAVEATS

Creating a VM only sets up its hardware configuration; it does not install an operating system.
Requires a unique VMID that is not already in use across the Proxmox cluster.
Disk and network configurations can be complex, necessitating specific syntax and existing storage/network resources.
Many advanced options exist, necessitating consultation of official documentation or qm create --help for full details.

VMID IMPORTANCE

The VMID is a mandatory, unique identifier for each virtual machine or container in Proxmox, ranging from 100 to 999,999,999. Choosing an appropriate and available VMID is the first step in creating a new VM, as it serves as the primary reference for all subsequent management operations.

DISK PROVISIONING VS. ATTACHMENT

When defining disks (e.g., with --scsi0), qm-create can automatically provision and format a new disk image on the specified storage backend with the given size and format. This is distinct from attaching a pre-existing disk image, which is typically done later using the qm set command.

CLOUD-INIT AUTOMATION

For guest operating systems supporting cloud-init, qm-create provides specific options like --ciuser, --cipassword, and --sshkeys. These allow for automated initial user setup, network configuration, and script execution upon the VM's first boot, significantly streamlining VM deployment for template-based scenarios.

HISTORY

qm-create has been a core component of the Proxmox Virtual Environment since its early versions, evolving to support modern virtualization features like UEFI, hotplugging, diverse storage technologies (e.g., ZFS, Ceph), and advanced CPU types. Its development mirrors the continuous enhancement of Proxmox VE as a robust, open-source hyper-converged platform, offering flexible and powerful command-line management capabilities for KVM guests and being integral to its growth.

SEE ALSO

qm(1), qm-start(1), qm-stop(1), qm-clone(1), qm-list(1), qm-set(1)

Copied to clipboard