Recover a VM with a corrupted or full disk  |  Compute Engine Documentation  |  Google Cloud (2024)

  • Home
  • Compute Engine
  • Documentation
  • Guides
Stay organized with collections Save and categorize content based on your preferences.

Linux Windows

If your VM is inaccessible or corrupted, you can recover the VM or its full bootdisk.

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'tresize it, you must create an instance and recreate the boot disk from asnapshot to resize it. You must know the size of the boot disk you'rerecreating.

Permissions required for this task

To perform this task, you must have the following permissions:

  • compute.instances.create on the project to be able to create a new instance
  • compute.disks.create on the project to be able to create a new disk
  • compute.disks.createSnapshot on the disk
  • compute.instances.attachDisk on the new VM instance
  • compute.disks.use permission on the disk to attach
  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

    1. Click the instance name to open the VM instance details page.
    2. Click Stop.
    3. In the Boot disk section, note the boot disk's sizeand name.
  2. In the Google Cloud console, go to the Create a snapshot page.

    Go to Create a snapshot

    1. Enter a snapshot Name.
    2. Select the boot disk from the Source disk drop-down list.
    3. Click Create.
  3. In the Google Cloud console, go to the Create an instance page.

    Go to Create an instance

  4. Enter the instance details.

  5. Create a new boot disk from the snapshot of the old boot disk.

    1. Under Boot disk, select Change.
    2. Select Snapshots.
    3. Select the snapshot of the old boot disk from the Snapshot drop-down list.
    4. Select the Boot disk type.
    5. Enter the new size for the disk.
    6. Click Select to confirm your disk options.
  6. Click Create.

Recovering a corrupted VM

If a VM's OS is corrupted, you can retrieve the boot disk data to recover theVM. To recover the boot disk, you must first create a temporary VM using aGoogle-provided image, because the snapshot of thesource VM might be corrupted.

To retrieve data from the VM, follow these steps:

  1. Create a snapshot from the boot disk of the source VM.
  2. Create a temporary VM using a public image.
  3. Check if you're able to connect to the temporary VM using SSH.
  4. Add an additional disk to the temporary VM by following these steps:

    1. In the Google Cloud console, go to the VM instances page.

      Go to VM instances

    2. Select the temporary VM that you created.

    3. Click edit Edit.

    4. Under Additional disks, click Add new disk, and then do thefollowing:

      1. Add the disk name.
      2. For Source type, select the Snapshot tab.
      3. In the Source snapshot drop-down menu, select the snapshot of thesource VM that you created earlier in these steps.
      4. Click Done.
    5. Click Save.

  5. Connect to the VM using SSH.

  6. Check the disk and partitions in the VM and make a note of the disk name—for example /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 
  7. Create a mount point at /mnt/newdisk:

     sudo mkdir /mnt/newdisk 
  8. Mount the additional disk partition to the mount point /mnt/newdisk:

     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, /dev/sdb1.

    The snapshot's file system is mounted at /mnt/newdisk. You can navigate thedirectories and retrieve data.

To create a VM with the recovered boot disk, follow these steps:

  1. Create an image from the disk of the temporary VM.
  2. Create a VM with the image of the temporary VM.

After the VM is created, you can transfer the recovered data to the VM.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-03-26 UTC.

Recover a VM with a corrupted or full disk  |  Compute Engine Documentation  |  Google Cloud (2024)
Top Articles
Latest Posts
Article information

Author: Frankie Dare

Last Updated:

Views: 5734

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Frankie Dare

Birthday: 2000-01-27

Address: Suite 313 45115 Caridad Freeway, Port Barabaraville, MS 66713

Phone: +3769542039359

Job: Sales Manager

Hobby: Baton twirling, Stand-up comedy, Leather crafting, Rugby, tabletop games, Jigsaw puzzles, Air sports

Introduction: My name is Frankie Dare, I am a funny, beautiful, proud, fair, pleasant, cheerful, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.