Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Se nel tuo ambiente on-premise hai dischi virtuali con software e
configurazioni di cui hai bisogno, a volte chiamati dischi dorati o
immagini dorate, puoi risparmiare tempo importando questi dischi virtuali in
Distributed Cloud e utilizzando l'immagine risultante per creare macchine
virtuali. Lo strumento di importazione supporta i formati immagine RAW e QCOW.
Prima di iniziare
Prima di continuare, assicurati di disporre di quanto segue:
gcloud CLI
scaricata, installata e configurata. Tutti i comandi CLI per
GDC utilizzano la CLI gdcloud o kubectl e richiedono
un ambiente del sistema operativo (OS).
Accesso di login al cluster Kubernetes. Segui i passaggi della CLI in
Accedi
per accedere al cluster Kubernetes.
Richiedere autorizzazioni e accesso
Per eseguire le attività elencate in questa pagina, devi disporre del ruolo Amministratore
macchina virtuale progetto. Segui i passaggi per
verificare
di disporre del ruolo Amministratore VirtualMachine progetto (project-vm-admin) nello spazio dei nomi
del progetto in cui si trova la VM.
Per le operazioni sulle VM che utilizzano la console GDC o gcloud CLI, chiedi all'amministratore IAM del progetto di assegnarti i ruoli elencati nel paragrafo precedente e il ruolo Visualizzatore progetto (project-viewer).
Per ottenere le autorizzazioni necessarie per importare le immagini, chiedi all'amministratore IAM dell'organizzazione di concederti il ruolo Amministratore immagini VirtualMachine progetto (project-vm-image-admin) per il tuo progetto.
gdcloud
Utilizza il comando gdcloud compute images import per creare un'immagine avviabile.
Il comando import garantisce che il disco disponga dei pacchetti richiesti, incluso l'ambiente guest, necessario per configurare le credenziali per la connessione all'istanza utilizzando Secure Shell (SSH) su Linux e Remote Desktop Protocol (RDP) su Windows.
Su Linux, il comando installa anche i pacchetti per il Network Time Protocol (NTP)
e cloud-init affinché l'istanza venga eseguita correttamente in
GDC.
Puoi importare i file del disco virtuale direttamente dalla tua workstation. Lo strumento di importazione
carica automaticamente il file in un bucket di archiviazione degli oggetti nel tuo
progetto.
IMAGE_NAME: il nome dell'immagine di destinazione. Il
nome non deve contenere più di 35 caratteri.
SOURCE_FILE: il file del disco virtuale. Questo file è un file locale sulla tua workstation. Puoi fornire un percorso assoluto o relativo.
IMAGE_OS: il sistema operativo sul disco da importare.
TIMEOUT: il tempo che può durare un'importazione prima che non vada a buon fine
con "TIMEOUT". Ad esempio, se specifichi 2h, il processo non va a buon fine dopo 2 ore.
Il timeout predefinito è 1h.
L'operazione di caricamento può richiedere un periodo di tempo prolungato a seconda delle dimensioni
del disco virtuale e della velocità della connessione di rete. L'operazione di importazione può richiedere decine di minuti per essere eseguita, a seconda delle dimensioni del disco.
API
Prima di avviare la procedura di importazione con l'API, devi caricare il disco virtuale in un bucket di archiviazione oggetti denominato vm-images-bucket. Per creare
un bucket di archiviazione oggetti, consulta
Creare bucket di archiviazione per i progetti.
Per importare un disco virtuale tramite l'API:
Crea un oggetto VirtualMachineImageImport nel server dell'API Management
per avviare il processo di importazione delle immagini:
Il nome dell'immagine da importare. Il nome non deve contenere più di 35 caratteri.
PROJECT_ID
L'ID progetto del progetto in cui vuoi importare l'immagine.
SOURCE_FILE
Il nome del file di origine che contiene il caricamento del disco virtuale nello spazio di archiviazione oggetti. Questo valore è la sezione del percorso di archiviazione di oggetti dopo vm-images-bucket/.
OPERATING_SYSTEM
Il sistema operativo sul disco da importare.
DISK_SIZE
La dimensione minima che deve avere un disco per essere creato con questa immagine. Ti consigliamo di utilizzare un buffer di almeno il 20% in aggiunta alle dimensioni del file system dell'immagine originale. Ad esempio, utilizza almeno 12Gi per un disco virtuale con dimensioni del file system originale di 10 Gi.
Monitora l'avanzamento dell'importazione eseguendo una query sullo stato dell'oggetto
VirtualMachineImageImport:
La procedura di importazione prevede il caricamento del file del disco virtuale nell'archiviazione degli oggetti.
Se utilizzi gcloud CLI, l'oggetto viene pulito al termine del comando, indipendentemente dall'esito. Se il comando viene interrotto o l'importazione dell'immagine viene eseguita con l'API, il file del disco virtuale potrebbe rimanere nel bucket di archiviazione degli oggetti denominato vm-images-bucket finché non lo elimini manualmente.
Passaggi successivi
Crea una nuova istanza VM che utilizza la tua immagine nella pagina
Crea e avvia una VM.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eYou can import on-premises virtual disks (RAW and QCOW formats) into Distributed Cloud to create reusable images for virtual machines, which helps save time and effort.\u003c/p\u003e\n"],["\u003cp\u003eImporting virtual disks can be accomplished either by using the \u003ccode\u003egdcloud\u003c/code\u003e CLI, which automatically uploads the file and installs necessary packages, or through the Virtual Machine Manager API after manually uploading the disk to an object storage bucket.\u003c/p\u003e\n"],["\u003cp\u003eBefore importing, you need the \u003ccode\u003egdcloud\u003c/code\u003e or \u003ccode\u003ekubectl\u003c/code\u003e CLI, access to the Kubernetes cluster, and the appropriate permissions, such as the Project VirtualMachine Image Admin role.\u003c/p\u003e\n"],["\u003cp\u003eThe import process, whether using the CLI or API, requires you to specify the image name, source file or bucket details, and the operating system of the disk being imported.\u003c/p\u003e\n"],["\u003cp\u003eIf using the API to import virtual disks, you must manually manage and delete the virtual disk files in the \u003ccode\u003evm-images-bucket\u003c/code\u003e, but the CLI automatically cleans up the object storage upon command completion.\u003c/p\u003e\n"]]],[],null,["# Import virtual disks\n\nIf you have virtual disks in your on-premises environment with software and\nconfigurations that you need, occasionally referred to as *golden disks* or\n*golden images*, you can save time by importing those virtual disks into\nDistributed Cloud and using the resulting image to create virtual\nmachines. The import tool supports RAW and QCOW image formats.\n\nBefore you begin\n----------------\n\nBefore continuing, ensure that you have the following:\n\n- The [gdcloud CLI](/distributed-cloud/hosted/docs/latest/gdch/resources/gdcloud-overview) downloaded, installed, and configured. All CLI commands for GDC use the `gdcloud` or `kubectl` CLI, and require an operating system (OS) environment.\n\n\u003c!-- --\u003e\n\n- Login access to the Kubernetes cluster. Follow the CLI steps in\n [Sign in](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/iam/sign-in#cli)\n to sign in to the Kubernetes cluster.\n\n | **Note:** Record the path to the generated file, `/tmp/admin-kubeconfig-with-user-identity.yaml`. Use the path to replace \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e in these instructions.\n\n### Request permissions and access\n\nTo perform the tasks listed in this page, you must have the Project\nVirtualMachine Admin role. Follow the steps to\n[verify](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/preparation#verify-user-access)\nthat you have the Project VirtualMachine Admin (`project-vm-admin`) role in the namespace\nof the project where the VM resides.\n\nFor VM operations using the GDC console or the gdcloud CLI,\nrequest your Project IAM Admin to assign you the roles listed in the previous\nparagraph and the Project Viewer (`project-viewer`) role.\n\nImport virtual disks\n--------------------\n\nYou can import your virtual disks using either the\ngdcloud CLI or the\n[Virtual Machine Manager API](/distributed-cloud/hosted/docs/latest/gdch/apis/service/virtualmachine/vmm-api-overview).\n\nTo get the permissions you need to import images, ask your Organization IAM\nAdmin to grant you the Project VirtualMachine Image Admin\n(`project-vm-image-admin`) role for your project. \n\n### gdcloud\n\nUse the `gdcloud compute images import` command to create a bootable image.\n\nThe `import` command ensures that the disk has the required packages,\nincluding the guest environment, which is required to configure credentials\nfor connecting to the instance using secure shell (SSH) on Linux and Remote\nDesktop Protocol (RDP) on Windows.\n\nOn Linux, the command also installs packages for network time protocol (NTP)\nand `cloud-init` for the instance to run properly in\nGDC.\n\nYou can import virtual disk files directly from your workstation. The import\ntool automatically uploads the file to an object storage bucket in your\nproject. \n\n gdcloud compute images import \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e \\\n --source-file=\u003cvar translate=\"no\"\u003eSOURCE_FILE\u003c/var\u003e \\\n --os=\u003cvar translate=\"no\"\u003eIMAGE_OS\u003c/var\u003e \\\n --timeout=\u003cvar translate=\"no\"\u003eTIMEOUT\u003c/var\u003e\n\nReplace the following variables:\n\n- \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e: the name of your destination image. The name must be no longer than 35 characters.\n- \u003cvar translate=\"no\"\u003eSOURCE_FILE\u003c/var\u003e: your virtual disk file. This file is a local file on your workstation. You can provide an absolute or relative path.\n- \u003cvar translate=\"no\"\u003eIMAGE_OS\u003c/var\u003e: the OS on the disk to import.\n- \u003cvar translate=\"no\"\u003eTIMEOUT\u003c/var\u003e: the time an import can last before it fails with \"TIMEOUT\". For example, if you specify `2h`, the process fails after 2 hours. The default timeout is `1h`.\n\nThe upload operation can take an extended period of time depending on the size\nof your virtual disk and the speed of your network connection. The import\noperation can take tens of minutes to run depending on the size of the disk.\n\n\u003cbr /\u003e\n\n### API\n\nBefore starting the import process with the API, you need to upload your\nvirtual disk to an object storage bucket named `vm-images-bucket`. To create\nan object storage bucket, see\n[Create storage buckets for projects](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/create-storage-buckets).\n\nTo import a virtual disk through the API, do the following:\n\n1. Create a `VirtualMachineImageImport` object in the Management API server\n to start the image import process:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e \\\n apply -n \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e -f - \u003c\u003cEOF\n apiVersion: virtualmachine.gdc.goog/v1\n kind: VirtualMachineImageImport\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eIMAGE_NAME\u003c/span\u003e\u003c/var\u003e\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003ePROJECT_ID\u003c/span\u003e\u003c/var\u003e\n spec:\n source:\n objectStorage:\n bucketRef:\n name: vm-images-bucket\n objectName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSOURCE_FILE\u003c/span\u003e\u003c/var\u003e\n imageMetadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eIMAGE_NAME\u003c/span\u003e\u003c/var\u003e\n operatingSystem: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eOPERATING_SYSTEM\u003c/span\u003e\u003c/var\u003e\n minimumDiskSize: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDISK_SIZE\u003c/span\u003e\u003c/var\u003e\n EOF\n\n Replace the following variables:\n\n2. Monitor the progress of the import by querying the status of the\n `VirtualMachineImageImport` object:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e \\\n get virtualmachineimageimport --namespace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e -o jsonpath='{.status}'\n\n### Clean up resources\n\nThe import process involves uploading your virtual disk file to object storage.\nIf you use the gdcloud CLI, the object is cleaned up when the command\nfinishes, whether or not it was successful. If the command is interrupted, or\nthe image import is done with the API, the virtual disk file might remain in\nthe object storage bucket named `vm-images-bucket` until you manually delete\nthe file.\n\nWhat's next\n-----------\n\nCreate a new VM instance that uses your image in the page,\n[Create and start a VM](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/create-a-vm/create-and-start)."]]