If your VM is inaccessible or corrupted, you can recover the VM or its full boot disk.
Recovering an inaccessible VM or a full boot disk
If you can't connect to your instance, or your boot disk is full and you can't resize it, you must create an instance and recreate the boot disk from a snapshot to resize it. You must know the size of the boot disk you're recreating.
Permissions required for this task
To perform this task, you must have the following permissions:
compute.instances.createon the project to be able to create a new instance
compute.disks.createon the project to be able to create a new disk
compute.disks.createSnapshoton the disk
compute.instances.attachDiskon the new VM instance
compute.disks.usepermission on the disk to attach
In the Google Cloud console, go to the VM instances page.
- Click the instance name to open the VM instance details page.
- Click 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.
- Select the boot disk from the Source disk drop-down list.
- Click Create.
In the Google Cloud console, go to the Create an instance page.
Enter the instance details.
Create a new boot disk from the snapshot of the old boot disk.
- Under Boot disk, select Change.
- Select Snapshots.
- Select the snapshot of the old boot disk from the Snapshot drop-down list.
- Select the Boot disk type.
- Enter the new size for the disk.
- Click Select to confirm your disk options.
Recovering a corrupted VM
If a VM's OS is corrupted, you can retrieve the boot disk data to recover the VM. To recover the boot disk, you must first create a temporary VM using a Google-provided image, because the snapshot of the source VM might be corrupted.
To retrieve data from the VM, follow these steps:
- Create a snapshot from the boot disk of the source VM.
- Create a temporary VM using a public image.
- Check if you're able to connect to the temporary VM using SSH.
Add an additional disk to the temporary VM by following these steps:
In the Cloud console, go to the VM instances page.
Select the temporary VM that you created.
Under Additional disks, click Add new disk, and then do the following:
- Add the disk name.
- For Source type, select the Snapshot tab.
- In the Source snapshot drop-down menu, select the snapshot of the source VM that you created earlier in these steps.
- Click Done.
Connect to the VM using SSH.
Check the disk and partitions in the VM and make a note of the disk name—for example
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
sudo mkdir /mnt/newdisk
Mount the additional disk partition to the mount point
sudo mount -o discard,defaults DISK_NAME /mnt/newdisk
Replace DISK_NAME with the disk name that you noted earlier in these steps—for example,
The snapshot's file system is mounted at
/mnt/newdisk. You can navigate the directories and retrieve data.
To create a VM with the recovered boot disk, follow these steps:
After the VM is created, you can transfer the recovered data to the VM.