Skip to content
Tutorials Center
My learning

Topics

Lesson 19 of 45 ยท Storage and Databases

Persistent Disk, Local SSD and Filestore

Learn block, file and object storage on Google Cloud: disk types, snapshots, Local SSD and Filestore, plus a storage chooser you can run to practice.

Cloud Storage holds objects, but a virtual machine also needs a place to keep its operating system, a database's files, or a folder that several servers share. Google Cloud offers three families of storage for that: block storage for a single machine's disk, file storage for a shared folder, and object storage for files you fetch by name over HTTP.

This lesson explains each family, the disk types you can attach to a Compute Engine VM, how snapshots protect your data, and how to choose. Product names, sizes, speeds and prices change often, so treat every number here as an illustration and check Google's current documentation before you design anything real.

Block, file and object storage

Three ways to store data

Block A raw disk that one VM formats and mounts.
File A shared folder many machines mount at once.
Object Whole files fetched by name over HTTP.

Pick by how your software reads and writes data.

1 / 2
  • Block storage looks like a hard drive. The operating system formats it (for example with ext4) and reads and writes small pieces anywhere in it. Databases and boot volumes want this.
  • File storage looks like a network folder using the NFS protocol. Many machines can read and write the same files at the same time. Content management systems and shared build caches use this.
  • Object storage stores immutable whole objects in buckets. It scales hugely and is cheap, but you cannot edit the middle of an object. See Cloud Storage Buckets and Objects.

Persistent Disk

A Persistent Disk is network-attached block storage. Because the disk lives apart from the VM, it survives when the VM is stopped, and it can be detached and attached to another VM in the same zone. Data is stored redundantly by Google, so one failed drive does not lose your data.

Typical disk types, from cheapest to fastest (names and limits vary by version and machine family, so confirm current options):

Type Backed by Good for
Standard (pd-standard) Hard drives Large sequential data, backups, low cost
Balanced (pd-balanced) SSD The common default for boot disks and general workloads
SSD (pd-ssd) SSD Databases that need more input/output operations per second
Extreme (pd-extreme) SSD Very demanding databases, with provisioned IOPS

Newer machine families use Hyperdisk, a successor family whose performance (IOPS and throughput) you can set separately from its size. Which disks a VM can use depends on its machine type, so the console shows only the compatible choices.

Key facts:

  • A disk is zonal (one zone) or regional (replicated synchronously across two zones in a region). A regional disk lets you restart a VM in the second zone if the first zone fails. It costs more and writes slightly slower.
  • Disks can be resized upward while attached. You then grow the file system inside the VM. You cannot shrink a disk.
  • Performance usually grows with disk size, up to a limit, so a tiny disk can be slower than a larger one of the same type.
  • Data is encrypted at rest by default; you can bring your own key with Cloud KMS (Secret Manager and Cloud KMS).
  • A disk keeps billing even when its VM is stopped, because the storage still exists. Forgotten disks are a classic source of surprise charges.
Terminal
# Create a balanced disk, attach it to a VM, then format and mount it inside the VM
# (needs a real project; shown read-only)
gcloud compute disks create data-disk \
  --size=200GB --type=pd-balanced --zone=europe-west1-b

gcloud compute instances attach-disk web-1 \
  --disk=data-disk --zone=europe-west1-b

# Inside the VM:
sudo mkfs.ext4 -m 0 /dev/disk/by-id/google-data-disk
sudo mkdir -p /mnt/data
sudo mount /dev/disk/by-id/google-data-disk /mnt/data

For virtual machines in general, see Compute Engine Virtual Machines.

Local SSD

A Local SSD is a drive physically attached to the server your VM runs on. It has very high speed and low latency, but it is ephemeral: the data is lost if the VM is deleted or the host fails in some situations. Use it for scratch space, caches and temporary processing, never as the only copy of data you care about.

The usual pattern is to keep the real data on a Persistent Disk (or in Cloud Storage or a database) and use Local SSD for fast temporary files that can be rebuilt.

Snapshots and images

A snapshot is a point-in-time copy of a disk stored outside the disk itself. The first snapshot copies everything; later snapshots are incremental and store only changed blocks, so they are cheaper and quicker. You can restore a snapshot to a new disk, even in another zone or region.

  • Create snapshots on a schedule (a snapshot schedule resource) and set how many days to keep them.
  • A snapshot taken while a database is writing is only crash-consistent, like pulling the power cord. For important databases, flush or pause writes first, or use the database's own backup tools.
  • Deleting an old snapshot is safe for the others, because Google keeps the data blocks that newer snapshots still need.
  • An image is different: it is a template used to create boot disks (see Compute Engine), while a snapshot is a backup of one disk's contents.
Terminal
# Snapshot a disk and restore it to a new disk (read-only example)
gcloud compute disks snapshot data-disk \
  --snapshot-names=data-2025-01-15 --zone=europe-west1-b

gcloud compute disks create data-restored \
  --source-snapshot=data-2025-01-15 --zone=europe-west1-c

Filestore

Filestore is a managed NFS file server. You create an instance with a capacity and a service tier, and your VMs (or GKE pods) mount it as a shared directory. Tiers range from basic options for simple sharing up to enterprise options with higher availability across zones; the exact tier names and minimum sizes change, so check the current list.

Use Filestore when several machines must see the same files at the same moment: a web farm sharing uploads, render nodes sharing assets, or applications that need a POSIX file system but cannot use object storage. It costs more per gigabyte than Cloud Storage, so do not use it for data that could simply live in a bucket.

Terminal
# Mount a Filestore share inside a VM (read-only example)
sudo apt-get install -y nfs-common
sudo mkdir -p /mnt/shared
sudo mount 10.0.0.2:/share1 /mnt/shared

Choosing storage

Ask a few questions in order:

  1. Does the software need a file system path? If not (web assets, backups, data lake files), pick Cloud Storage.
  2. Does one machine use it, with random reads and writes? Pick a Persistent Disk (or Hyperdisk).
  3. Do many machines need the same files at once? Pick Filestore.
  4. Is it temporary and speed matters more than safety? Add a Local SSD.

The code below is a stand-in for that decision. Google has no such function; it only encodes the questions above so you can see the logic and try different scenarios.

JS A storage chooser

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Snapshot schedules matter too. The next stand-in models a retention rule: take a snapshot every day and keep only the newest N. It shows which snapshots remain, and why storing "all of them forever" is rarely wise.

JS Daily snapshots with retention

Press Run (or Ctrl + Enter) to see the console output here.

No output.

What is real and what is the stand-in: the gcloud commands and disk facts above are real Google Cloud behavior (verify details in the docs), but nothing on this page creates a disk. The TryIts only model decisions and retention logic in plain JavaScript.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which storage type lets many VMs mount the same folder at the same time?

    Filestore is a managed NFS server, so multiple machines can read and write one shared file system. A Persistent Disk is meant for one VM.
  2. 2. What is the main risk of storing your only copy of important data on a Local SSD?

    Local SSDs are fast scratch space attached to the host. Keep durable data on Persistent Disk, Cloud Storage or a database.
  3. 3. After the first snapshot of a disk, later snapshots are...

    Snapshots are incremental, which makes them quicker and cheaper. You can still restore any one snapshot to a complete disk.
  4. 4. Your VM is stopped but its Persistent Disk still exists. What happens to billing for the disk?

    You pay for provisioned disk capacity whether or not the VM runs. Delete disks you no longer need.

Summary

  • Block storage (Persistent Disk, Hyperdisk) is a drive for one VM; file storage (Filestore) is a shared NFS folder; object storage (Cloud Storage) holds whole objects.
  • Disks are zonal or regional, can be grown but not shrunk, and keep billing until deleted.
  • Local SSD is very fast but ephemeral: use it for scratch data only.
  • Snapshots are incremental backups you can schedule, keep for a set time and restore into new disks.
  • Choose storage by access pattern: file system needed, how many machines, how critical, how temporary.

Next: Cloud SQL