您可以從作業系統映像檔或磁碟映像檔建立虛擬機器 (VM) 執行個體。本文說明如何判斷 VM 的來源 OS 映像檔或來源磁碟映像檔。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Trusted Cloud by S3NS 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
- Set a default region and zone.
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
詳情請參閱 Trusted Cloud 驗證說明文件中的「Authenticate for using REST」。
查看 VM 的來源 OS 映像檔或來源磁碟映像檔
如要查看 VM 的來源 OS 映像檔或來源磁碟映像檔,請使用Trusted Cloud 主控台、Google Cloud CLI 或 Compute Engine API。
主控台
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
按一下 VM 的「名稱」。
來源 OS 映像檔或來源磁碟映像檔的名稱位於「儲存空間」>「開機磁碟」>「映像檔」。
gcloud
使用下列
gcloud compute instances describe
指令,查看附加至 VM 的磁碟:gcloud compute instances describe VM_NAME
將
VM_NAME
替換為 VM 名稱。使用下列
gcloud compute disks describe
指令,查看磁碟的來源 OS 映像檔或來源磁碟映像檔:gcloud compute disks describe DISK_NAME \ --zone=ZONE \ --format="get(SOURCE)"
更改下列內容:
DISK_NAME
:要查看來源的磁碟名稱。ZONE
:磁碟所在的可用區。SOURCE
:指定是否要傳回來源 OS 映像檔或來源磁碟映像檔的值。設為sourceDisk
或sourceImage
。指定sourceDisk
或sourceImage
時,除非有對應的來源 OS 映像檔或來源磁碟映像檔,否則不會傳回任何值。如果沒有傳回任何值,請指定其他值,然後再次執行指令。
REST
使用下列
instances.get
方法,查看附加至 VM 的磁碟:GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME
更改下列內容:
PROJECT_ID
:專案 IDZONE
:包含 VM 的可用區VM_NAME
:VM 名稱
使用
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
:專案 IDZONE
:包含磁碟的可用區DISK_NAME
:磁碟名稱
後續步驟
- 進一步瞭解 Compute Engine 的作業系統映像檔。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-08 (世界標準時間)。"],[[["This guide explains how to identify the source OS image or source disk image used to create a virtual machine (VM) instance."],["You can determine the source image using the Google Cloud console, the Google Cloud CLI (gcloud), or the Compute Engine API."],["To access and use the services, authentication is needed and the methods to authenticate are explained for the Google Cloud Console, the gcloud CLI, and REST."],["Required permissions include `compute.instances.get` on the specific VM instance."],["The location of the required source image information can be found in the storage section under the boot disk in the Google Cloud Console and by using the gcloud command lines to view the disk and then its source."]]],[]] -