A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/compute/docs/images/creating-an-image-from-an-iso-file below:

Create a persistent disk image from an ISO file | Compute Engine Documentation

Create a persistent disk image from an ISO file

Stay organized with collections Save and categorize content based on your preferences.

Windows

Installation media for Windows applications is often provided as an ISO file, but Compute Engine does not let you expose an ISO file as a virtual DVD drive to a VM instance.

To access the contents of the ISO file on a single Windows VM, you can do either of the following:

This document describes how you can create a Persistent Disk from the ISO file and attach the disk in read-only mode to one or more VMs.

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. Before you begin Prepare the ISO file

If the ISO file is publicly available via HTTP, you do not need to download the ISO file first. To use a local ISO file, you can upload the ISO file to Cloud Storage.

Create a disk containing the contents of the ISO file

To copy the contents of the ISO file to a new disk, create a temporary VM, then create an image from the disk:

  1. From Cloud Shell, specify the name that you want to assign to the new disk:

    DISK_NAME=iso
    
  2. Create a new disk to which to copy the contents of the ISO files:

    gcloud compute disks create $DISK_NAME \
      --size=10GB \
      --zone=$(gcloud config get-value compute/zone)
    

    Use a larger disk size if your ISO file exceeds 9 GB.

  3. Create a startup script for the temporary VM. The startup script performs the following actions:

    1. Format the secondary disk with the NTFS file system.
    2. Download the ISO file from the HTTP or Cloud Storage URL you specified.
    3. Mount the ISO file and copy its contents to the secondary disk.
    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
    EOF
    
  4. Create a Windows Server 2019 VM that uses the startup script and the disk that you created previously:

    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_only
    

    The VM takes about 2 minutes to start. Depending on the size of the ISO file, it can take another 5-15 minutes for the file copy operation to complete. You can observe the progress by running the following command:

    gcloud compute instances tail-serial-port-output iso-copier \
        --zone=$(gcloud config get-value compute/zone)
    
  5. Wait for the VM to finish running the startup script:

    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...
    done
    
  6. Shut down and delete the VM:

    gcloud compute instances delete iso-copier \
        --zone=$(gcloud config get-value compute/zone) \
        --quiet
    

    Notice that the secondary disk is not deleted because it was mounted with the parameter auto-delete=no.

The disk is now ready to be used. You can attach the disk in read-only mode to one or more VM instances within the same zone.

Share the disk across zones and regions by creating an image

To make the contents of the ISO file available in other zones or regions, create a Compute Engine image:

  1. From Cloud Shell, create an image from the disk that you created in the previous section:

    gcloud compute images create $DISK_NAME \
        --source-disk=$DISK_NAME \
        --source-disk-zone=$(gcloud config get-value compute/zone)
    
Clean up

To avoid incurring further costs after you have completed this process, you can delete the resources that you created:

  1. Delete the disk:

    gcloud compute disks delete $DISK_NAME \
        --zone=$(gcloud config get-value compute/zone) \
        --quiet
    
  2. Delete the image:

    gcloud compute images delete $DISK_NAME
    
What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Compute 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."],["To 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."],["A 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."],["After 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."],["To extend the availability of the ISO contents to other zones or regions, you can create a Compute Engine image from the disk."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4