Use symbolic links to access disks attached to a Linux VM Stay organized with collections Save and categorize content based on your preferences.
When you attach a disk to a virtual machine (VM) that uses a Linux OS,Google Cloud automatically creates a symbolic link (symlink) for the disk. Toaccess Persistent Disk volumes or Local SSD disks in your Linux VM, use thesymlinks. These symlinks are predictable and remain consistent across reboots.Google Cloud creates symlinks for all disks attached to a VM in/dev/disk/by-id.
This document explains how to identify the correct symlinks for the disksattached to a VM.
Format of symbolic links
Symlinks are created in/dev/disk/by-id when a disk is attached to the VM,either during or after VM creation. The symlink names are created as follows:
Persistent Disk and Google Cloud Hyperdisk
The symlinks are created using the following rules:
- If you specified a custom device name when you created the disk:
google-DEVICE_NAME - If you didn't specify a custom device name when you created the disk:
- Boot disk:
google-VM_NAME - Non-boot disk:
google-DISK_NAME
- Boot disk:
After you format the disk, the symlink is appended with-partN, whereN is the partition number,for examplegoogle-data-disk-part1.
Local SSD disks
Local SSD symlinks have different formats depending on the disk interface.
- SCSI:
- If you specified a custom device name when you created the disk:
google-DEVICE_NAME - If you didn't specify a custom device name when you created the disk:
google-local-ssd-N, whereN is the Local SSD disk number, starting from 0.
- If you specified a custom device name when you created the disk:
- NVMe: The symlinks are named
google-local-nvme-ssd-N,whereN is the SSD number, starting from 0.
After you format a Local SSD disk, the symlink is appended with-partN, whereN is the partition number,for example,google-local-nvme-ssd-0-part1.
Device symlinks
Compute Engine creates additional symlinks in the directory based on the disktype and interface, for examplescsi-0Google_PersistentDisk_DEVICE_NAME.These links perform the same function as the symlinks mentioned previously.
Example 1: C3 VM with attached Local SSD
Assume you created a VM with the following properties:
- VM name:
instance-1 - Machine series: C3
- Disk interface type: NVMe for both Persistent Disk and Local SSD
- Additional disks: none
- Attached Local SSD disks: 2
- Custom device names used: none
Compute Engine creates the following symlinks for that VM:
ls-l/dev/disk/by-id/google-*google-instance-1 -> ../../nvme2n1google-instance-1-part1 -> ../../nvme2n1p1google-instance-1-part14 -> ../../nvme2n1p14google-instance-1-part15 -> ../../nvme2n1p15google-local-nvme-ssd-0 -> ../../nvme0n1google-local-nvme-ssd-1 -> ../../nvme1n1In this example, the Persistent Disk boot disk symlink isgoogle-instance-1, whichis based on the VM name. The boot disk is formatted and has the operating systeminstalled on it. The boot disk has 3 partitions: part1, part14, and part 15.The attached Local SSD disks are not formatted, soonly a single symlink was created for each Local SSD disk.
Example 2: N2 VM with attached NVMe Local SSD and extra Persistent Disk
Assume you created a VM with the following properties:
- VM name:
instance-2 - Machine series: N2
- Disk interface type: SCSI for Persistent Disk and NVMe for Local SSD
- Additional disks: 1 Persistent Disk named
extra-scsi-disk - Attached Local SSD disks: 2
- Custom device names used: none
The following symlinks are created for that VM:
ls-l/dev/disk/by-id/google-*google-extra-scsi-disk -> ../../sdbgoogle-instance-2 -> ../../sdagoogle-instance-2-part1 -> ../../sda1google-instance-2-part14 -> ../../sda14google-instance-2-part15 -> ../../sda15google-local-nvme-ssd-0 -> ../../nvme0n1google-local-nvme-ssd-0-part1 -> ../../nvme0n1p1google-local-nvme-ssd-1 -> ../../nvme0n2In this example, the Persistent Disk boot disk symlink isgoogle-instance-2, whichis based on the VM name. The boot disk is formatted and has the OS imageinstalled on it. The boot disk has 3 partitions: part1, part14, and part 15.The first Local SSD disk is also partitioned, with a single partition, sothere is an additional symlink created for that disk partition.The additional Persistent Disk added to the VM has thesymlinkgoogle-extra-scsi-disk, which is based the disk name. The extraPersistent Disk and second Local SSD disk are not formatted,so only a single symlink is listed for those disks.
What's next
- Learn how touse persistent device names.
- Format and mount your new disks onLinuxorWindows VMs.
- Learn how tobenchmark Persistent Disk performance.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.