Recover a Compute Engine instance with a full or corrupted boot disk by recreating the disk from a snapshot or by using a temporary instance.
Recover an inaccessible compute instance or a full boot disk
If you can't connect to your compute instance, or if your boot disk is full and you can't resize it, then you must create a compute instance and recreate the boot disk from a snapshot to resize it. You must know the size of the boot disk that you're recreating.
In the Google Cloud console, go to the VM instances page.
- Click the name of the compute instance to open the VM instance details page.
- Click Stop to stop the compute instance. If there's no Stop option, then click More actions > Stop.
- In the Boot disk section, note the boot disk's size and name.
In the Google Cloud console, go to the Create a snapshot page.
- Enter a snapshot Name.
- In the Source disk list, select the boot disk.
- Click Create.
In the Google Cloud console, go to the Create an instance page.
Enter the compute instance details.
Create a boot disk from the snapshot of the original boot disk:
- Under Boot disk, select Change.
- Select Snapshots.
- In the Snapshot list, select the snapshot of the original boot disk.
- Select the Boot disk type.
- In the Size field, enter a size that is larger than the original boot disk.
- Click Select to confirm your disk options.
Click Create.
Recover a corrupted compute instance
If a compute instance's operating system is corrupted, then you can retrieve the boot disk data to recover the compute instance. To recover the boot disk, first create a temporary compute instance by using a Google-provided image because the snapshot of the source compute instance might be corrupted.
To retrieve data from the compute instance, follow these steps:
- Create a snapshot from the boot disk of the source compute instance.
- Create a temporary compute instance by using a public image. If the original boot disk is full, then provision sufficient free space on the temporary instance's boot disk to avoid a full-disk error.
- Check if you can connect to the temporary compute instance by using SSH.
Add an additional disk to the temporary compute instance by following these steps:
In the Google Cloud console, go to the VM instances page.
Select the temporary compute instance that you created.
Click Edit.
Under Additional disks, click Add new disk, and then do the following:
- In the Name field, enter a disk name.
- For Source type, select the Snapshot tab.
- In the Source snapshot list, select the snapshot of the source compute instance that you created earlier in these steps.
- In the Size field, specify the disk size. If the original boot disk is 100% full, then enter a size larger than the original boot disk.
- Click Done.
Click Save.
Connect to the temporary compute instance and mount the disk:
For Windows compute instances, follow the steps in Format and mount a non-boot disk on a Windows VM.
For Linux compute instances, follow these steps:
- Connect to the compute instance by using SSH.
Check the disk and partitions on the compute instance and note the disk name, such as
/dev/sdb1:lsblk
The output is similar to the following:
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
Create a mount point at the
/mnt/newdiskdirectory:sudo mkdir /mnt/newdisk
Mount the additional disk partition to the
/mnt/newdiskmount point:sudo mount -o discard,defaults DISK_NAME /mnt/newdisk
Replace
DISK_NAMEwith the disk name that you noted earlier in these steps, such as/dev/sdb1.The snapshot's file system is mounted at the
/mnt/newdiskdirectory. You can navigate the directories and retrieve data.
To create a compute instance that uses the recovered boot disk, follow these steps:
- Create an image from the disk of the temporary compute instance.
- Create a compute instance from the custom image.
After Compute Engine creates the compute instance, you can transfer the recovered data to that compute instance. You incur costs for the temporary compute instance and the disk snapshot until you delete them. To delete these resources after you recover your data, see Delete an instance and Delete a snapshot.
Recover a Windows compute instance that requires a BitLocker recovery key
If a Windows compute instance fails to boot or if you restore the instance from a snapshot and it requires a BitLocker recovery key, then you can unlock the disk by attaching it to a temporary compute instance. Complete the following steps:
- Back up the disk by taking a standard snapshot of the disk.
- Create a temporary Windows compute instance that's in the same zone as the failed compute instance.
- Attach the encrypted disk as a data disk to the temporary compute instance:
- Stop the failed compute instance.
- Detach the boot disk from the failed compute instance.
- Attach the boot disk as a secondary data disk to the temporary compute instance.
- Connect to the temporary compute instance and mount the attached disk.
- Retrieve the BitLocker recovery key from Active Directory by using the BitLocker Recovery Password Viewer tool or PowerShell.
- Use the recovery key to unlock the disk.
You incur costs for the temporary compute instance and the disk snapshot until you delete them. To delete these resources after you recover your data, see Delete an instance and Delete a snapshot.