Criar uma imagem de disco permanente a partir de um arquivo ISO
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Windows
A mídia de instalação de aplicativos do Windows geralmente é fornecida como um arquivo ISO.
No entanto, o Compute Engine não permite expor um arquivo ISO como uma unidade de DVD virtual para uma
instância de VM.
Para acessar o conteúdo do arquivo ISO em uma única VM do Windows, siga um destes
procedimentos:
Copie o arquivo ISO para a VM e ative-o localmente. Essa abordagem funciona bem se você
só precisar acessar o conteúdo do arquivo ISO em uma única instância de VM.
Crie um disco permanente no arquivo ISO e conecte o disco no modo somente leitura
a uma ou mais instâncias de VM. Essa abordagem funciona bem se várias VMs precisarem acessar o conteúdo do arquivo ISO.
Neste documento, você verá como criar um disco permanente no arquivo ISO e
anexar o disco no modo somente leitura a uma ou mais VMs.
Antes de começar
Configure a autenticação, caso ainda não tenha feito isso.
A autenticação é
o processo de verificação da sua identidade para acesso a serviços e APIs do Google Cloud .
Para executar códigos ou amostras de um ambiente de desenvolvimento local, autentique-se no
Compute Engine selecionando uma das seguintes opções:
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
Instale a CLI do Google Cloud.
Após a instalação,
inicialize a Google Cloud CLI executando o seguinte comando:
Se o arquivo ISO estiver disponível publicamente via HTTP, você não precisará fazer o download do arquivo ISO primeiro. Para usar um arquivo ISO local, faça upload do arquivo ISO para o Cloud Storage.
URL HTTP
No console Google Cloud , abra o
Cloud Shell
clicando no
botão Ativar o Cloud Shell.
A VM leva cerca de dois minutos para ser iniciada. Dependendo do tamanho do arquivo ISO, pode levar de cinco a 15 minutos para que a operação de cópia de arquivos seja concluída. Para observar o progresso, execute o seguinte comando:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 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)."]]