- Create a VM for debugging in the same project as the boot disk you want to inspect. Set up the SSH connection to your new VM.
- Stop the original VM that you want to inspect. Otherwise, you can’t attach its boot disk to another VM.
-
Get the ID of the original VM’s boot disk:
-
Attach the boot disk to the debug VM as a secondary disk:
- Connect to the debug VM by using SSH.
-
List the partitions and filesystems on the boot disk:
-
Mount the filesystem you need to inspect. The root filesystem is on the largest ext4 (or xfs) partition — usually
-part1. To mount it:For safety, use the-o roparameter to mount the filesystem in read-only mode. This prevents any accidental changes to the boot disk you are inspecting. -
(Optional) If you need to repair the filesystem by writing to it, remount it in read-write mode:
-
When done inspecting, unmount the filesystem:
- Detach the boot disk of the original VM from the debug VM.
- After the disk is detached, start the original VM. You can’t start the VM if its boot disk is attached to another running VM.
Troubleshooting
How to inspect a VM and attach its boot disk to another VM
If a virtual machine (VM) does not start or you cannot connect to it, you can attach its boot disk to another VM as a secondary disk and inspect the boot disk from there. To do this: