I supporti di installazione per le applicazioni Windows vengono spesso forniti come file ISO, ma Compute Engine non ti consente di esporre un file ISO come unità DVD virtuale a un'istanza VM.
Per accedere ai contenuti del file ISO su una singola VM Windows, puoi svolgere una delle seguenti operazioni:
Copia il file ISO nella VM e montalo localmente. Ti consigliamo di adottare questo approccio se devi accedere solo ai contenuti del file ISO su una singola istanza VM.
Crea un disco permanente dal file ISO e collegalo in modalità di sola lettura a una o più istanze VM. Ti consigliamo di adottare questo approccio se più VM devono accedere ai contenuti del file ISO.
Questo documento descrive come creare un disco permanente dal file ISO e collegarlo in modalità di sola lettura a una o più VM.
Prima di iniziare
-
Se non l'hai ancora fatto, configura l'autenticazione.
L'autenticazione è il processo mediante il quale la tua identità viene verificata per l'accesso a servizi e API di Google Cloud
Per eseguire codice o esempi da un ambiente di sviluppo locale, puoi autenticarti su
Compute Engine selezionando una delle seguenti opzioni:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud initIf you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
Prepara il file ISO
Se il file ISO è disponibile pubblicamente tramite HTTP, non devi scaricarlo prima. Per utilizzare un file ISO locale, puoi caricarlo su Cloud Storage.
URL HTTP
Nella console Google Cloud , apri Cloud Shell facendo clic sul pulsante Attiva Cloud Shell
.
Crea una variabile di ambiente per l'URL di download. L'URL può essere un URL HTTP o HTTPS, ma deve essere accessibile in modo anonimo.
ISO_URL=https://example.com/big.iso
File ISO locale
Nella console Google Cloud , crea un bucket Cloud Storage.
-
A seconda delle dimensioni del file ISO, il caricamento può richiedere diversi minuti o ore.
Nel browser di storage, vai all'oggetto caricato.
Nella pagina Dettagli oggetto, copia l'URI dell'oggetto. L'URI inizia con
gs://.Per aprire Cloud Shell, fai clic sul pulsante Attiva Cloud Shell
.
Crea una variabile di ambiente per l'URL di download. Sostituisci
URIcon l'URI che hai copiato.ISO_URL=URI
Crea un disco contenente i contenuti del file ISO
Per copiare i contenuti del file ISO su un nuovo disco, crea prima una VM temporanea e successivamente un'immagine dal disco:
Da Cloud Shell, specifica il nome da assegnare al nuovo disco:
DISK_NAME=isoCrea un nuovo disco su cui copiare i contenuti dei file ISO:
gcloud compute disks create $DISK_NAME \ --size=10GB \ --zone=$(gcloud config get-value compute/zone)
Se il file ISO supera i 9 GB, utilizza una dimensione del disco maggiore.
Crea uno script di avvio per la VM temporanea. Lo script di avvio esegue queste azioni:
- Formatta il disco secondario con il file system NTFS.
- Scarica il file ISO dall'URL HTTP o Cloud Storage specificato.
- Monta il file ISO e copiane i contenuti sul disco secondario.
cat << "EOF" > startup.ps1 $DownloadDirectory = 'c:\download\' $ErrorActionPreference = 'Stop' $MetadataUrl = 'http://metadata.google.internal/computeMetadata/v1/instance' $DownloadUrl = (Invoke-RestMethod ` -Headers @{"Metadata-Flavor" = "Google"} ` -Uri "$MetadataUrl/attributes/iso") mkdir $DownloadDirectory\Source -Force Write-Host '== Formatting secondary disk... ===' -ForegroundColor Black -BackgroundColor Yellow Set-Disk -Number 1 -IsOffline $false Clear-Disk -Number 1 -RemoveData -Confirm:$false -ErrorAction SilentlyContinue Initialize-Disk -Number 1 -PartitionStyle MBR New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter D -IsActive | Format-Volume -FileSystem 'NTFS' -Confirm:$false Write-Host '== Downloading ISO... =============' -ForegroundColor Black -BackgroundColor Yellow if ($DownloadUrl.StartsWith('gs:')) { & gcloud storage cp $DownloadUrl "$DownloadDirectory\Source\image.iso" | Out-Default } else { Import-Module BitsTransfer Start-BitsTransfer -Source $DownloadUrl -Destination "$DownloadDirectory\Source\image.iso" } Write-Host '== Mounting ISO... ================' -ForegroundColor Black -BackgroundColor Yellow Mount-DiskImage -ImagePath "$DownloadDirectory\Source\image.iso" -StorageType ISO Write-Host '== Copying ISO contents... ========' -ForegroundColor Black -BackgroundColor Yellow Copy-Item 'e:\*' 'd:\' -Force -Recurse -PassThru ` | Where-Object { -Not $_.PSIsContainer } ` | Set-ItemProperty -Name IsReadOnly -Value $False Write-Host '== Completed. =====================' -ForegroundColor Black -BackgroundColor Yellow Invoke-RestMethod ` -Headers @{'Metadata-Flavor'='Google'} ` -Method PUT ` -Uri "$MetadataUrl/guest-attributes/vm/ready" ` -Body true EOFCrea una VM Windows Server 2019 che utilizzi lo script di avvio e il disco che hai creato in precedenza:
gcloud compute instances create iso-copier \ --machine-type=n1-standard-2 \ --image-family=windows-2019-core \ --image-project=windows-cloud \ --disk=name=$DISK_NAME,auto-delete=no \ --metadata=enable-guest-attributes=true,iso=$ISO_URL \ --metadata-from-file=windows-startup-script-ps1=startup.ps1 \ --scopes=https://www.googleapis.com/auth/devstorage.read_onlyL'avvio della VM richiede circa 2 minuti. A seconda delle dimensioni del file ISO, potrebbero essere necessari altri 5-15 minuti per completare l'operazione di copia del file. Puoi osservare l'avanzamento eseguendo questo comando:
gcloud compute instances tail-serial-port-output iso-copier \ --zone=$(gcloud config get-value compute/zone)Attendi che la VM finisca di eseguire lo script di avvio:
until gcloud compute instances get-guest-attributes iso-copier \ --zone=$(gcloud config get-value compute/zone) \ --query-path=vm/ready > /dev/null 2>&1 do sleep 5 && echo waiting for VM to finish... doneArresta ed elimina la VM:
gcloud compute instances delete iso-copier \ --zone=$(gcloud config get-value compute/zone) \ --quietTieni presente che il disco secondario non può essere eliminato perché è stato montato con il parametro
auto-delete=no.
Il disco è ora pronto per essere utilizzato. Puoi collegare il disco in modalità di sola lettura a una o più istanze VM all'interno della stessa zona.
Condividi il disco tra zone e regioni creando un'immagine
Per rendere disponibili i contenuti del file ISO in altre zone o regioni, crea un'immagine Compute Engine:
Da Cloud Shell, genera un'immagine dal disco creato nella sezione precedente:
gcloud compute images create $DISK_NAME \ --source-disk=$DISK_NAME \ --source-disk-zone=$(gcloud config get-value compute/zone)
Esegui la pulizia
Per evitare di incorrere in ulteriori costi dopo aver completato questa procedura, puoi eliminare le risorse che hai creato:
Elimina il disco:
gcloud compute disks delete $DISK_NAME \ --zone=$(gcloud config get-value compute/zone) \ --quietElimina l'immagine:
gcloud compute images delete $DISK_NAME
Passaggi successivi
Scopri come creare immagini personalizzate.
Scopri come gestire l'accesso alle immagini personalizzate.
Scopri di più sui workload Windows su Compute Engine.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-09-04 UTC.
[[["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\u003eCompute Engine cannot directly expose an ISO file as a virtual DVD drive to a VM instance, but provides two methods to access the ISO contents: locally mounting the file on a single VM or creating a Persistent Disk for read-only access by multiple VMs.\u003c/p\u003e\n"],["\u003cp\u003eTo prepare an ISO file for use, it can either be accessed publicly via HTTP or uploaded to Cloud Storage if it's a local file.\u003c/p\u003e\n"],["\u003cp\u003eA temporary VM is used to copy the ISO file contents onto a new disk, which involves formatting the disk, downloading the ISO, mounting it, and copying its contents, handled by a startup script.\u003c/p\u003e\n"],["\u003cp\u003eAfter the contents are copied, the temporary VM can be shut down and deleted, and the new Persistent Disk can then be attached in read-only mode to one or more VM instances.\u003c/p\u003e\n"],["\u003cp\u003eTo extend the availability of the ISO contents to other zones or regions, you can create a Compute Engine image from the disk.\u003c/p\u003e\n"]]],[],null,["# Create a persistent disk image from an ISO file\n\nWindows\n\n*** ** * ** ***\n\nInstallation media for Windows applications is often provided as an ISO file,\nbut Compute Engine does not let you expose an ISO file as a virtual DVD drive to a\nVM instance.\n\nTo access the contents of the ISO file on a single Windows VM, you can do either\nof the following:\n\n- Copy the ISO file to the VM and [mount it locally](https://docs.microsoft.com/en-us/powershell/module/storage/mount-diskimage?view=win10-ps). This approach works well if you\n only need to access the contents of the ISO file on a single VM instance.\n\n- Create a Persistent Disk from the ISO file and attach the disk in read-only mode\n to one or more VM instances. This approach works well if multiple VMs need\n access to the contents of the ISO file.\n\nThis document describes how you can create a Persistent Disk from the ISO file and\nattach the disk in read-only mode to one or more VMs.\n| **Note:** The process described in this document does not apply to creating bootable operating system images from ISO files. For creating a bootable operating system image, see [Creating custom Windows BYOL images](/compute/docs/images/creating-custom-windows-byol-images).\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\nPrepare the ISO file\n--------------------\n\nIf the ISO file is publicly available via HTTP, you do not need to download\nthe ISO file first. To use a local ISO file, you can upload the ISO file to\nCloud Storage. \n\n### HTTP URL\n\n1. In the Google Cloud console, open\n [Cloud Shell](/shell/docs/using-cloud-shell)\n by clicking the\n **Activate Cloud Shell**\n button.\n\n [Go to the Google Cloud console](https://console.cloud.google.com/)\n2. Create an environment variable for the download URL. The URL can be\n an HTTP or HTTPS URL, but it must be accessible anonymously.\n\n ```\n ISO_URL=https://example.com/big.iso\n ```\n\n### Local ISO file\n\n1. In the Google Cloud console, [create a Cloud Storage bucket](/storage/docs/creating-buckets).\n\n [Go to the Google Cloud console](https://console.cloud.google.com/)\n2. [Upload the ISO file](/storage/docs/uploading-objects).\n\n Depending on the size of the ISO file, the upload can take several\n minutes or hours.\n3. In the [Storage browser](https://console.cloud.google.com/storage/browser), navigate to\n the uploaded object.\n\n4. On the **Object details** page, copy the URI of the object. The URI\n starts with `gs://`.\n\n5. Open [Cloud Shell](/shell/docs/using-cloud-shell)\n by clicking the\n **Activate Cloud Shell**\n button.\n\n [Go to the Google Cloud console](https://console.cloud.google.com/)\n6. Create an environment variable for the download URL. Replace\n \u003cvar translate=\"no\"\u003eURI\u003c/var\u003e with the URI that you copied.\n\n ```\n ISO_URL=URI\n ```\n\nCreate a disk containing the contents of the ISO file\n-----------------------------------------------------\n\nTo copy the contents of the ISO file to a new disk, create a temporary VM, then\ncreate an image from the disk:\n\n1. From Cloud Shell, specify the name that you want to assign to the new\n disk:\n\n DISK_NAME=iso\n\n2. Create a new disk to which to copy the contents of the ISO files:\n\n ```\n gcloud compute disks create $DISK_NAME \\\n --size=10GB \\\n --zone=$(gcloud config get-value compute/zone)\n ```\n\n Use a larger disk size if your ISO file exceeds 9 GB.\n3. Create a startup script for the temporary VM. The startup script performs\n the following actions:\n\n 1. Format the secondary disk with the NTFS file system.\n 2. Download the ISO file from the HTTP or Cloud Storage URL you specified.\n 3. Mount the ISO file and copy its contents to the secondary disk.\n\n ```\n cat \u003c\u003c \"EOF\" \u003e startup.ps1\n\n $DownloadDirectory = 'c:\\download\\'\n $ErrorActionPreference = 'Stop'\n $MetadataUrl = 'http://metadata.google.internal/computeMetadata/v1/instance'\n\n $DownloadUrl = (Invoke-RestMethod `\n -Headers @{\"Metadata-Flavor\" = \"Google\"} `\n -Uri \"$MetadataUrl/attributes/iso\")\n\n mkdir $DownloadDirectory\\Source -Force\n\n Write-Host '== Formatting secondary disk... ===' -ForegroundColor Black -BackgroundColor Yellow\n Set-Disk -Number 1 -IsOffline $false\n Clear-Disk -Number 1 -RemoveData -Confirm:$false -ErrorAction SilentlyContinue\n Initialize-Disk -Number 1 -PartitionStyle MBR\n New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter D -IsActive |\n Format-Volume -FileSystem 'NTFS' -Confirm:$false\n\n Write-Host '== Downloading ISO... =============' -ForegroundColor Black -BackgroundColor Yellow\n if ($DownloadUrl.StartsWith('gs:')) {\n & gcloud storage cp $DownloadUrl \"$DownloadDirectory\\Source\\image.iso\" | Out-Default\n }\n else {\n Import-Module BitsTransfer\n Start-BitsTransfer -Source $DownloadUrl -Destination \"$DownloadDirectory\\Source\\image.iso\"\n }\n\n Write-Host '== Mounting ISO... ================' -ForegroundColor Black -BackgroundColor Yellow\n Mount-DiskImage -ImagePath \"$DownloadDirectory\\Source\\image.iso\" -StorageType ISO\n\n Write-Host '== Copying ISO contents... ========' -ForegroundColor Black -BackgroundColor Yellow\n Copy-Item 'e:\\*' 'd:\\' -Force -Recurse -PassThru `\n | Where-Object { -Not $_.PSIsContainer } `\n | Set-ItemProperty -Name IsReadOnly -Value $False\n\n Write-Host '== Completed. =====================' -ForegroundColor Black -BackgroundColor Yellow\n Invoke-RestMethod `\n -Headers @{'Metadata-Flavor'='Google'} `\n -Method PUT `\n -Uri \"$MetadataUrl/guest-attributes/vm/ready\" `\n -Body true\n EOF\n ```\n4. Create a Windows Server 2019 VM that uses the startup script and the disk\n that you created previously:\n\n ```\n gcloud compute instances create iso-copier \\\n --machine-type=n1-standard-2 \\\n --image-family=windows-2019-core \\\n --image-project=windows-cloud \\\n --disk=name=$DISK_NAME,auto-delete=no \\\n --metadata=enable-guest-attributes=true,iso=$ISO_URL \\\n --metadata-from-file=windows-startup-script-ps1=startup.ps1 \\\n --scopes=https://www.googleapis.com/auth/devstorage.read_only\n ```\n\n The VM takes about 2 minutes to start. Depending on the size of the\n ISO file, it can take another 5-15 minutes for the file copy operation\n to complete. You can observe the progress by running the following\n command: \n\n ```\n gcloud compute instances tail-serial-port-output iso-copier \\\n --zone=$(gcloud config get-value compute/zone)\n ```\n5. Wait for the VM to finish running the startup script:\n\n ```\n until gcloud compute instances get-guest-attributes iso-copier \\\n --zone=$(gcloud config get-value compute/zone) \\\n --query-path=vm/ready \u003e /dev/null 2\u003e&1\n do\n sleep 5 && echo waiting for VM to finish...\n done\n ```\n6. Shut down and delete the VM:\n\n ```\n gcloud compute instances delete iso-copier \\\n --zone=$(gcloud config get-value compute/zone) \\\n --quiet\n ```\n\n Notice that the secondary disk is not deleted because it was mounted with\n the parameter `auto-delete=no`.\n\nThe disk is now ready to be used. You can [attach the disk in read-only mode\nto one or more VM instances](/compute/docs/disks/sharing-disks-between-vms)\nwithin the same zone.\n\nShare the disk across zones and regions by creating an image\n------------------------------------------------------------\n\nTo make the contents of the ISO file available in other zones or regions,\ncreate a Compute Engine image:\n\n1. From Cloud Shell, create an image from the disk that you created in the\n previous section:\n\n ```\n gcloud compute images create $DISK_NAME \\\n --source-disk=$DISK_NAME \\\n --source-disk-zone=$(gcloud config get-value compute/zone)\n ```\n\nClean up\n--------\n\nTo avoid incurring further costs after you have completed this process, you\ncan delete the resources that you created:\n\n1. Delete the disk:\n\n ```\n gcloud compute disks delete $DISK_NAME \\\n --zone=$(gcloud config get-value compute/zone) \\\n --quiet\n ```\n2. Delete the image:\n\n ```\n gcloud compute images delete $DISK_NAME\n ```\n\nWhat's next\n-----------\n\n- Learn how to\n [create custom images](/compute/docs/images/create-delete-deprecate-private-images).\n\n- Learn how to\n [manage access to custom images](/compute/docs/images/managing-access-custom-images).\n\n- Learn more about\n [Windows workloads on Compute Engine](/compute/docs/instances/windows)."]] -