`qm disk import` command examples (with examples)

`qm disk import` command examples (with examples)

1: Import a VMDK/qcow2/raw disk image using a specific storage name

qm importdisk 100 /var/images/disk.vmdk local --format vmdk

Motivation: This example demonstrates how to import a disk image in either VMDK, qcow2, or raw format to a virtual machine with the ID 100. The disk image is located at /var/images/disk.vmdk, and it will be imported to the storage named local. The specified format for the disk image is VMDK.

Explanation of Arguments:

  • qm importdisk: The command for importing a disk image.
  • 100: The ID of the virtual machine where the disk will be imported.
  • /var/images/disk.vmdk: The path to the disk image file.
  • local: The name of the storage where the disk image will be imported.
  • --format vmdk: The format of the disk image file. It can be either vmdk, qcow2, or raw.

Example Output: The specified VMDK disk image (disk.vmdk) will be imported to the virtual machine with the ID of 100 and stored in the local storage.

2: Import a RAW disk image to a virtual machine without specifying the storage name

qm importdisk 101 /var/images/disk.raw --format raw

Motivation: This example shows how to import a RAW disk image to a virtual machine without specifying a storage name. By omitting the storage name, the imported disk will be stored in the default local storage.

Explanation of Arguments:

  • qm importdisk: The command for importing a disk image.
  • 101: The ID of the virtual machine where the disk will be imported.
  • /var/images/disk.raw: The path to the disk image file.
  • --format raw: The format of the disk image file, which is RAW.

Example Output: The specified RAW disk image (disk.raw) will be imported to the virtual machine with the ID of 101 and stored in the default local storage.

3: Import a qcow2 disk image using a specific storage name and an alternate format

qm importdisk 102 /var/images/disk.qcow2 alternate_storage --format vmdk

Motivation: This example demonstrates how to import a qcow2 disk image to a virtual machine with a specific storage name (alternate_storage). Additionally, it shows how to specify an alternate format (vmdk) for the imported disk image.

Explanation of Arguments:

  • qm importdisk: The command for importing a disk image.
  • 102: The ID of the virtual machine where the disk will be imported.
  • /var/images/disk.qcow2: The path to the disk image file.
  • alternate_storage: The name of the storage where the disk image will be imported.
  • --format vmdk: The format of the disk image file, which is set to VMDK as an alternative format.

Example Output: The specified qcow2 disk image (disk.qcow2) will be imported to the virtual machine with the ID of 102 and stored in the alternate_storage storage. However, it will be converted to the VMDK format during the import process.

Related Posts

How to use the command "expect" (with examples)

How to use the command "expect" (with examples)

The “expect” command is a script executor that interacts with other programs that require user input.

Read More
How to use the command git am (with examples)

How to use the command git am (with examples)

The git am command is used to apply patch files and create a commit.

Read More
How to use the command 'declare' (with examples)

How to use the command 'declare' (with examples)

The ‘declare’ command in Bash is used to declare variables and assign them attributes.

Read More