8.8.3.3. Creating a VM from a cloned PVC by using a data volume template


You can create a virtual machine (VM) that clones the persistent volume claim (PVC) of an existing VM by using a data volume template. This method creates a data volume whose lifecycle is independent on the original VM.

Prerequisites

  • The VM with the source PVC must be powered down.
  • You have installed the virtctl CLI.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create a VirtualMachine manifest for your VM and save it as a YAML file, for example:

    $ virtctl create vm --name rhel-9-clone --volume-import type:pvc,src:my-project/imported-volume-q5pr9
  2. Review the VirtualMachine manifest for your VM:

    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: rhel-9-clone 
    1
    
    spec:
      dataVolumeTemplates:
      - metadata:
          name: imported-volume-h4qn8
        spec:
          source:
            pvc:
              name: imported-volume-q5pr9 
    2
    
              namespace: my-project 
    3
    
          storage:
            resources: {}
      instancetype:
        inferFromVolume: imported-volume-h4qn8 
    4
    
        inferFromVolumeFailurePolicy: Ignore
      preference:
        inferFromVolume: imported-volume-h4qn8 
    5
    
        inferFromVolumeFailurePolicy: Ignore
      runStrategy: Always
      template:
        spec:
          domain:
            devices: {}
            memory:
              guest: 512Mi
            resources: {}
          terminationGracePeriodSeconds: 180
          volumes:
          - dataVolume:
              name: imported-volume-h4qn8
            name: imported-volume-h4qn8
    1
    The VM name.
    2
    The name of the source PVC.
    3
    The namespace of the source PVC.
    4
    If the PVC source has appropriate labels, the instance type is inferred from the selected DataSource object.
    5
    If the PVC source has appropriate labels, the preference is inferred from the selected DataSource object.
  3. Create the virtual machine with the PVC-cloned data volume:

    $ oc create -f <vm_manifest_file>.yaml
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る