查看 VM 的來源映像檔

您可以從作業系統映像檔或磁碟映像檔建立虛擬機器 (VM) 執行個體。本文說明如何判斷 VM 的來源 OS 映像檔或來源磁碟映像檔。

事前準備

  • 如果尚未設定驗證,請先完成設定。 驗證可確認您的身分,以便存取 Google Cloud 服務和 API。如要從本機開發環境執行程式碼或範例,可以選取下列任一選項,向 Compute Engine 進行驗證:

    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

    1. Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:

      gcloud init

      If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    2. Set a default region and zone.
    3. REST

      如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。

        Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:

        gcloud init

        If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

      詳情請參閱 Google Cloud 驗證說明文件中的「使用 REST 進行驗證」。

查看 VM 的來源 OS 映像檔或來源磁碟映像檔

如要查看 VM 的來源 OS 映像檔或來源磁碟映像檔,請使用Google Cloud 主控台、Google Cloud CLI 或 Compute Engine API。

控制台

  1. 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面

    前往 VM 執行個體

  2. 按一下 VM 的「名稱」

  3. 來源 OS 映像檔或來源磁碟映像檔的名稱位於「儲存空間」>「開機磁碟」>「映像檔」

gcloud

  1. 使用下列gcloud compute instances describe指令,查看連結至 VM 的磁碟:

    gcloud compute instances describe VM_NAME
    

    VM_NAME 替換為 VM 名稱。

  2. 使用下列 gcloud compute disks describe 指令,查看磁碟的來源 OS 映像檔或來源磁碟映像檔:

    gcloud compute disks describe DISK_NAME \
       --zone=ZONE \
       --format="get(SOURCE)"
    

    更改下列內容:

    • DISK_NAME:要查看來源的磁碟名稱。

    • ZONE:磁碟所在的可用區。

    • SOURCE:指定是否要傳回來源 OS 映像檔或來源磁碟映像檔的值。設為 sourceDisksourceImage。指定 sourceDisksourceImage 時,除非有對應的來源 OS 映像檔或來源磁碟映像檔,否則不會傳回任何值。如果沒有傳回任何值,請指定其他值,然後再次執行指令。

REST

  1. 使用下列instances.get方法,查看連結至 VM 的磁碟:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME
    

    更改下列內容:

    • PROJECT_ID:專案 ID
    • ZONE:包含 VM 的可用區
    • VM_NAME:VM 的名稱
  2. 使用 disks.get 方法,查看磁碟的來源 OS 映像檔或來源磁碟映像檔。

    如果是具有來源 OS 映像檔的 VM,這個方法會在 sourceImage 欄位中傳回用於建立磁碟的來源映像檔。如果 VM 具有來源磁碟映像檔,這個方法會在 sourceDisk 欄位中傳回來源映像檔。

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/disks/DISK_NAME
    

    更改下列內容:

    • PROJECT_ID:專案 ID
    • ZONE:包含磁碟的可用區
    • DISK_NAME:磁碟名稱

後續步驟