Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Windows
Media penginstalan untuk aplikasi Windows sering disediakan sebagai file ISO,
tetapi Compute Engine tidak memungkinkan Anda mengekspos file ISO sebagai drive DVD virtual ke instance VM.
Untuk mengakses konten file ISO di satu VM Windows, Anda dapat melakukan salah satu
tindakan berikut:
Salin file ISO ke VM dan pasang secara lokal. Pendekatan ini berfungsi dengan baik jika Anda
hanya perlu mengakses konten file ISO di satu instance VM.
Buat Persistent Disk dari file ISO dan pasang disk dalam mode hanya baca
ke satu atau beberapa instance VM. Pendekatan ini berfungsi dengan baik jika beberapa VM memerlukan
akses ke konten file ISO.
Dokumen ini menjelaskan cara membuat Persistent Disk dari file ISO dan memasang disk dalam mode hanya baca ke satu atau beberapa VM.
Sebelum memulai
Jika Anda belum melakukannya, siapkan autentikasi.
Autentikasi adalah
proses yang digunakan untuk memverifikasi identitas Anda untuk mengakses Google Cloud layanan dan API.
Untuk menjalankan kode atau sampel dari lingkungan pengembangan lokal, Anda dapat melakukan autentikasi ke
Compute Engine dengan memilih salah satu opsi berikut:
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
Menginstal Google Cloud CLI.
Setelah penginstalan,
lakukan inisialisasi Google Cloud CLI dengan menjalankan perintah berikut:
Jika file ISO tersedia secara publik melalui HTTP, Anda tidak perlu mendownload
file ISO terlebih dahulu. Untuk menggunakan file ISO lokal, Anda dapat mengupload file ISO ke
Cloud Storage.
URL HTTP
Di konsol Google Cloud , buka
Cloud Shell
dengan mengklik tombol
Aktifkan Cloud Shell.
VM memerlukan waktu sekitar 2 menit untuk dimulai. Bergantung pada ukuran file ISO, perlu waktu 5-15 menit lagi agar operasi penyalinan file selesai. Anda dapat mengamati progresnya dengan menjalankan perintah berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]