本頁面中的部分或全部資訊可能不適用於 Trusted Cloud by S3NS。
復原磁碟損毀或磁碟已滿的 VM
如果 VM 無法存取或已損毀,您可以復原 VM 或整個開機磁碟。
復原無法存取的 VM 或整個開機磁碟
如果無法連線至執行個體,或者開機磁碟已滿且無法調整其大小,那麼您必須建立一個執行個體,然後從快照重新建立開機磁碟來調整其大小。您必須知道要重新建立的開機磁碟大小。
這項工作需要的權限
如要執行這項工作,您必須具備以下權限:
- 專案的
compute.instances.create
權限 (這樣才能建立新執行個體)
- 專案的
compute.disks.create
權限 (這樣才能建立新磁碟)
- 磁碟的
compute.disks.createSnapshot
權限
- 新 VM 執行個體的
compute.instances.attachDisk
權限
- 所要連接磁碟的
compute.disks.use
權限
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
前往 VM 執行個體
- 按一下執行個體名稱,開啟「VM instance details」(VM 執行個體詳細資料) 頁面。
- 按一下「停止」stop即可停止 VM。如果沒有「停止」選項,請依序點選 more_vert「更多動作」> stop「停止」。
- 在「Boot disk」(開機磁碟) 區段,記下開機磁碟的大小和名稱。
前往 Trusted Cloud 控制台的「建立快照」頁面。
前往「建立快照」
- 輸入快照的「Name」(名稱)。
- 從「Source disk」(來源磁碟) 下拉式清單中選取開機磁碟。
- 點選「建立」。
前往 Trusted Cloud 控制台的「Create an instance」(建立執行個體) 頁面。
前往「建立執行個體」
輸入執行個體的詳細資料。
根據舊開機磁碟的快照建立新開機磁碟。
- 選取「Boot disk」(開機磁碟) 下方的「Change」(變更)。
- 選取快照。
- 從「Snapshot」(快照) 下拉式清單中選取舊開機磁碟的快照。
- 選取開機磁碟類型。
- 輸入磁碟的新大小。
- 按一下「Select」(選取) 來確認開機磁碟選項。
點選「建立」。
復原已損毀的 VM
如果 VM 的 OS 毀損,您可以擷取開機磁碟資料來復原 VM。如要復原開機磁碟,您必須先使用 Google 提供的映像檔建立臨時 VM,因為來源 VM 的快照可能已損毀。
如要從 VM 擷取資料,請按照下列步驟操作:
- 從來源 VM 的開機磁碟建立快照。
- 使用公開映像檔建立臨時 VM。
- 確認您是否能使用 SSH 連線至臨時 VM。
按照下列步驟,將額外磁碟新增至臨時 VM:
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
前往 VM 執行個體
選取您建立的暫時性 VM。
按一下「Edit」(編輯)edit。
在「Additional disks」(其他磁碟) 底下,按一下「Add new disk」(增加新磁碟),然後執行下列操作:
- 新增磁碟名稱。
- 在「來源類型」部分,選取「快照」分頁標籤。
- 在「Source snapshot」(來源快照) 下拉式選單中,選取您在先前步驟中建立的來源 VM 快照。
- 按一下 [完成]。
按一下 [儲存]。
使用 SSH 連線至 VM。
檢查 VM 中的磁碟和分割區,並記下磁碟名稱,例如 /dev/sdb1
:
lsblk
輸出結果會與下列內容相似:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10G 0 disk
└─sda1 8:1 0 10G 0 part /
sdb 8:16 0 100G 0 disk
├─sdb1 8:17 0 96G 0 part
├─sdb2 8:18 0 1K 0 part
└─sdb5 8:21 0 4G 0 part
在 /mnt/newdisk
建立掛接點:
sudo mkdir /mnt/newdisk
將額外磁碟分割區掛接至掛接點 /mnt/newdisk
:
sudo mount -o discard,defaults DISK_NAME /mnt/newdisk
將 DISK_NAME 換成您在這些步驟中稍早記下的磁碟名稱,例如 /dev/sdb1
。
快照的檔案系統會掛接在 /mnt/newdisk
。您可以瀏覽目錄並擷取資料。
如要使用復原的開機磁碟建立 VM,請按照下列步驟操作:
- 從臨時 VM 的磁碟建立映像檔。
- 使用臨時 VM 的映像檔建立 VM。
建立 VM 後,您可以將復原的資料轉移至 VM。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-18 (世界標準時間)。
[[["容易理解","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-18 (世界標準時間)。"],[[["\u003cp\u003eIf your VM is inaccessible or its boot disk is full, you can recover it by creating a new instance and recreating the boot disk from a snapshot, ensuring you know the original boot disk size.\u003c/p\u003e\n"],["\u003cp\u003eTo recover a corrupted VM's data, you can create a snapshot of the boot disk, create a temporary VM with a Google-provided image, and attach the snapshot as an additional disk.\u003c/p\u003e\n"],["\u003cp\u003eTo access the data from a snapshot, you need to identify the disk name within the temporary VM, create a mount point, and mount the additional disk partition to that mount point.\u003c/p\u003e\n"],["\u003cp\u003eCreating an image from the disk of a temporary VM will allow you to create a new VM with the recovered boot disk and then you can transfer your data.\u003c/p\u003e\n"],["\u003cp\u003eSpecific permissions like \u003ccode\u003ecompute.instances.create\u003c/code\u003e and \u003ccode\u003ecompute.disks.create\u003c/code\u003e are required to create new instances and disks during the recovery process, as well as snapshot and attachment permissions.\u003c/p\u003e\n"]]],[],null,["# Recover a VM with a corrupted or full disk\n\nLinux Windows\n\n*** ** * ** ***\n\nIf your VM is inaccessible or corrupted, you can recover the VM or its full boot\ndisk.\n\nRecovering an inaccessible VM or a full boot disk\n-------------------------------------------------\n\nIf you can't connect to your instance, or your boot disk is full and you can't\nresize it, you must create an instance and recreate the boot disk from a\nsnapshot to resize it. You must know the size of the boot disk you're\nrecreating.\n\n#### Permissions required for this task\n\nTo perform this task, you must have the following\n[permissions](/iam/docs/overview#permissions):\n\n\n- `compute.instances.create` on the project to be able to create a new instance\n- `compute.disks.create` on the project to be able to create a new disk\n- `compute.disks.createSnapshot` on the disk\n- `compute.instances.attachDisk` on the new VM instance\n- `compute.disks.use` permission on the disk to attach\n\n1. In the Google Cloud console, go to the **VM instances** page.\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n 1. Click the instance name to open the **VM instance details** page.\n 2. Click stop **Stop** to stop the VM. If there is no **Stop** option, click more_vert **More actions \\\u003e** stop **Stop**.\n 3. In the **Boot disk** section, note the boot disk's size and name.\n2. In the Google Cloud console, go to the **Create a snapshot** page.\n\n [Go to Create a snapshot](https://console.cloud.google.com/compute/snapshotsAdd)\n 1. Enter a snapshot **Name**.\n 2. Select the boot disk from the **Source disk** drop-down list.\n 3. Click **Create**.\n3. In the Google Cloud console, go to the **Create an instance** page.\n\n [Go to Create an instance](https://console.cloud.google.com/compute/instancesAdd)\n4. Enter the instance details.\n\n5. Create a new boot disk from the snapshot of the old boot disk.\n\n 1. Under **Boot disk** , select **Change**.\n 2. Select **Snapshots**.\n 3. Select the snapshot of the old boot disk from the **Snapshot** drop-down list.\n 4. Select the **Boot disk type**.\n 5. Enter the new size for the disk.\n 6. Click **Select** to confirm your disk options.\n6. Click **Create**.\n\nRecovering a corrupted VM\n-------------------------\n\nIf a VM's OS is corrupted, you can retrieve the boot disk data to recover the\nVM. To recover the boot disk, you must first create a temporary VM using a\n[Google-provided image](/compute/docs/images), because the snapshot of the\nsource VM might be corrupted.\n\nTo retrieve data from the VM, follow these steps:\n\n1. [Create a snapshot](/compute/docs/disks/create-snapshots#creating_snapshots) from the boot disk of the source VM.\n2. [Create a temporary VM using a public image](/compute/docs/images#os-compute-support).\n3. Check if you're able to [connect to the temporary VM](/compute/docs/instances/connecting-to-instance) using SSH.\n4. Add an additional disk to the temporary VM by following these steps:\n\n 1. In the Google Cloud console, go to the **VM instances** page.\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n 2. Select the temporary VM that you created.\n\n 3. Click edit **Edit**.\n\n 4. Under **Additional disks** , click **Add new disk**, and then do the\n following:\n\n 1. Add the disk name.\n 2. For **Source type** , select the **Snapshot** tab.\n 3. In the **Source snapshot** drop-down menu, select the snapshot of the source VM that you created earlier in these steps.\n 4. Click **Done**.\n 5. Click **Save**.\n\n5. [Connect to the VM](/compute/docs/instances/connecting-to-instance#connecting_to_vms)\n using SSH.\n\n6. Check the disk and partitions in the VM and make a note of the disk\n name---for example `/dev/sdb1`:\n\n \u003cbr /\u003e\n\n ```\n lsblk\n \n ```\n\n \u003cbr /\u003e\n\n The output is similar to the following:\n\n \u003cbr /\u003e\n\n ```\n NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\n sda 8:0 0 10G 0 disk\n └─sda1 8:1 0 10G 0 part /\n sdb 8:16 0 100G 0 disk\n ├─sdb1 8:17 0 96G 0 part\n ├─sdb2 8:18 0 1K 0 part\n └─sdb5 8:21 0 4G 0 part\n \n ```\n\n \u003cbr /\u003e\n\n7. Create a mount point at `/mnt/newdisk`:\n\n \u003cbr /\u003e\n\n ```\n sudo mkdir /mnt/newdisk\n \n ```\n\n \u003cbr /\u003e\n\n8. Mount the additional disk partition to the mount point `/mnt/newdisk`:\n\n \u003cbr /\u003e\n\n ```\n sudo mount -o discard,defaults DISK_NAME /mnt/newdisk\n \n ```\n\n \u003cbr /\u003e\n\n Replace \u003cvar translate=\"no\"\u003eDISK_NAME\u003c/var\u003e with the disk name that you noted earlier in\n these steps---for example,\n `/dev/sdb1`.\n\n The snapshot's file system is mounted at `/mnt/newdisk`. You can navigate the\n directories and retrieve data.\n\nTo create a VM with the recovered boot disk, follow these steps:\n\n1. [Create an image from the disk](/compute/docs/images/create-delete-deprecate-private-images#creating_a_custom_image) of the temporary VM.\n2. [Create a VM with the image](/compute/docs/instances/create-start-instance#create_a_vm_from_a_custom_image) of the temporary VM.\n\nAfter the VM is created, you can transfer the recovered data to the VM."]]