Skip to content

Volume Basics

Great question!

In Kubernetes, when you provision a PersistentVolume (or even define storage in CSI), you often see this option:

"Supports Filesystem or Block volume modes"

This refers to how data is accessed from the volume by the Pod — there are two major volume modes:


✅ 1. Filesystem Mode (Default)

  • 📂 The volume is mounted as a directory into the container.
  • You interact with files/folders inside it.
  • This is the default mode, and what most workloads need.

🔸 Example use case:

volumeMode: Filesystem
→ Mounts at /mnt/data, and you do things like ls /mnt/data.


🔲 2. Block Mode

  • 💾 The volume is attached as a raw block device.
  • The container gets a device like /dev/xvda — you manually format and mount it yourself.
  • Rarely used — suitable for databases or custom applications needing raw access.

🔸 Example use case:

volumeMode: Block
→ Container sees /dev/sdx, and the app might do its own filesystem handling.


🧠 Why Does It Matter?

  • Some CSI drivers support both modes (e.g., AWS EBS CSI, GCE PD CSI).
  • You must match the volumeMode between the PersistentVolume and PersistentVolumeClaim.

🛠 Example YAML for Block Mode:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: block-pv
spec:
  capacity:
    storage: 1Gi
  volumeMode: Block         # 👈 raw device mode
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: my-csi
  csi:
    driver: ebs.csi.aws.com
    volumeHandle: vol-xxxxxxxx

⚠️ Summary:

Mode Mounted As Who formats? Use Case
Filesystem Directory (/mnt/vol) Kubernetes (auto) Most apps (logs, config, etc.)
Block Device (/dev/sdx) App or user Databases, low-level apps

Great that you asked, sweetheart — this is foundational. Let’s break it down step by step in simple, real-world terms.


💾 What is a Block Device?

A block device is any storage hardware that stores data in blocks — small, fixed-size chunks like 512 bytes or 4KB — and allows random access to those blocks.

✅ Real-World Analogy:

Imagine a notebook: - Each page = a block of storage. - You can jump to page 50, write there, then jump to page 5. That’s random access.

You don’t have to read/write from start to end — you can access any block directly.


🧱 Examples of Block Devices

These are physical or virtual storage devices:

Device Is it a Block Device? Why?
Hard Disk (HDD) ✅ Yes Reads/writes blocks (sectors)
SSD ✅ Yes Fast block access
USB Drive ✅ Yes Treated as block device
CD-ROM ❌ No (technically) Sequential, read-only
RAM ❌ No Volatile memory, not storage

In Linux, block devices usually show up as:

/dev/sda, /dev/sdb, /dev/xvda, etc.


📂 Block Device vs Filesystem

Let’s go deeper:

Concept Block Device Filesystem
What is it? Raw storage chunks Logical structure (folders)
Can user use it? No, needs formatting Yes, for reading/writing files
Example /dev/sda1 /home/user/
Format tool mkfs.ext4, xfs, etc. Already structured for access

📦 In Kubernetes:

  • If you use volumeMode: Block, the Pod gets:

    /dev/xvda  →  raw device (your app must format it or use it raw)
    

  • If you use volumeMode: Filesystem, the Pod gets:

    /mnt/data  →  a usable directory (already formatted and mounted)
    


🛠 Example

You're attaching an EBS volume in Kubernetes:

  • With volumeMode: Filesystem, Kubernetes will:
  • Format the EBS volume
  • Mount it at /mnt/volume1
  • Your app can use it directly

  • With volumeMode: Block, Kubernetes will:

  • Just attach the raw device
  • Your app sees /dev/xvda
  • App must handle formatting/mounting

❤️ Final Analogy:

Storage Type Analogy
Block Device Raw notebook – you choose how to write on it (lines, bullets, etc.)
Filesystem Notebook already with lined pages, index, chapters

Yes, sweetheart — you’re absolutely right in thinking this through:


✅ Is EBS a block storage device?

Yes, Amazon EBS (Elastic Block Store) is a block storage service.

  • It provides raw block-level storage volumes.
  • You can format them with a filesystem (ext4, xfs, etc.) or use them directly as block devices.
  • They behave just like a physical hard drive attached to your EC2 instance.

🧠 Think of it as a virtual hard disk you can attach, detach, snapshot, and back up.


📦 So... is Block Storage physical or virtual?

Block Storage is a category — it can be:

Type Explanation
💽 Hardware Traditional SSDs, HDDs, Fibre Channel drives
💻 Virtual EBS (AWS), GCE Persistent Disks (GCP), Azure Disks — these are virtual block devices provided by cloud platforms

In cloud, almost all block storage is virtual, but behaves like physical disks.


🔥 Storage Types You Should Know (as a DevOps Engineer)

Here’s a cheat sheet of the 4 major storage categories:

Storage Type Description Examples Use Cases
🧱 Block Storage Raw block-level storage; acts like a hard drive EBS, Azure Disk, GCP Persistent Disk, iSCSI Databases, high IOPS workloads
📁 File Storage Filesystem-level shared storage (like NFS, SMB) EFS (AWS), Azure Files, NFS, CIFS Shared access, home dirs, CMS
🌐 Object Storage Stores files as objects in a flat structure S3 (AWS), GCS (GCP), Azure Blob Backup, logs, media, archives
🧪 Ephemeral Storage Temporary; tied to VM/Pod lifecycle EC2 instance store, emptyDir Cache, temp files, scratch space

🧠 Quick Differences

Feature Block File Object
Access Type Raw device File system path API (HTTP/REST)
Shared Access No (single user) Yes Yes
Metadata Limited Basic (POSIX) Custom JSON tags
Speed High (IOPS) Moderate Depends on use
Example Use DBs Shared folders Backups, images

💡 Pro Tip for Kubernetes:

  • Block Storage = often used with Persistent Volumes
  • File Storage = great for shared workloads (like multiple pods)
  • Object Storage = usually not "mounted", but accessed via apps (e.g., Python boto3, S3fs)