2023年1月6日 星期五

Detect if a VM is running in Google Compute Engine

Detect if a VM is running in Compute Engine

sudo dmidecode -s system-product-name | grep "Google Compute Engine"
這個需要 root 權限,實際上是去讀取 /sys/firmware/dmi/tables/DMI
用 strings /sys/firmware/dmi/tables/DMI | grep "Google Compute Engine" 也行

若程式沒有 root 權限,可以去讀取 /etc/hosts 有沒有包含 Added by Google 字樣
grep "Added by Google" /etc/hosts

沒有留言:

Migrate Google Compute Engine VM image to local

想要把 Google Compute Engine VM 備份,或者 clone 一份到 local 做測試 先關機建立映像檔,再把映像檔匯出到 Bucket (可以選擇匯出格式 vmdk、vhdx 等),然後就可以下載 但會發現在自己的環境無法開機,看起來是找不到 root ...