• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Linux File System: From “Everything is a File” to Your Disk Secrets

August 17, 2025

1. Introduction: From Physical Disk to File Universe

When you first run the ls -l command on a Linux server, you see a magical display of file information: names, permissions, sizes, timestamps… Have you ever wondered how this information is stored? How does Linux transform cold, physical disks into an organized file universe?

My first encounter with Linux file systems was challenging—I spent an entire night troubleshooting why my virtual machine’s disk wasn’t working, only to realize I forgot to format the partition. This experience sparked my fascination with Linux file systems. In this guide, we’ll explore the wonders of Linux file systems from a beginner’s perspective, using simple language to uncover their secrets.

2. Core Philosophy: “Everything is a File”

Linux follows a fascinating design principle: everything is a file. Whether it’s documents, directories, disks, keyboards, or network sockets, Linux treats them all as files. This unified interface makes Linux both simple and powerful.

2.1 Virtual File System (VFS): The Hidden Translator

The Virtual File System (VFS) is the backbone of this philosophy. It acts as a translator, providing standard operations (open(), read(), write()) while abstracting away differences between file systems (ext4, XFS, NFS) and storage types (HDD, SSD, network storage).

Example: Writing a log file on a VPS:

c
int fd = open("log.txt", O_WRONLY);
write(fd, "Hello, Linux!", 13);
close(fd);

VFS handles the underlying complexity—just like ordering food delivery without worrying about cooking or delivery logistics.

3. Disk Secrets: From Physical Structure to Logical Partitions

3.1 Physical Disk Structure

  • Platters: Magnetic-coated disks storing binary data.

  • Tracks: Concentric circles (like vinyl records).

  • Sectors: Small segments within tracks.

  • Cylinders: Same tracks across multiple platters.

Linux hides this complexity behind logical structures.

3.2 Partitioning: Dividing Disk “Territories”

Partitions define accessible regions on a disk. Tools like fdisk record partition boundaries in:

  • MBR (Master Boot Record): Legacy (≤2TB, 4 primary partitions).

  • GPT (GUID Partition Table): Modern (supports larger disks and more partitions).

Pro Tip: Always check partition table type when working with large disks!

3.3 Formatting: Creating a File System

Formatting a partition (e.g., ext4) creates:

  • Superblock: Metadata (block size, inode count, free space).

  • Block Group Descriptor Table (GDT): Tracks inode/data block locations.

  • Inode Table: Stores file metadata (excluding names).

  • Data Blocks: Actual file content storage.

4. File Storage & Access: The Magic of Inodes

4.1 Inode Structure

Each file/directory has a unique inode containing:

  • File type (regular, directory, link).

  • Permissions (read/write/execute).

  • Size, timestamps.

  • Pointers to data blocks.

Key Insight: Filenames are stored in directory data blocks, mapped to inode numbers—like a phonebook linking names to numbers.

4.2 File Creation Workflow

Creating test.txt involves:

  1. Finding a free inode.

  2. Writing metadata to the inode table.

  3. Adding filename-to-inode mapping in the directory.

  4. Allocating data blocks for content.

4.3 File Access Path

Running cat /var/log/test.txt triggers:

  1. Root (/) → var inode lookup.

  2. var → log inode lookup.

  3. log → test.txt inode lookup.

  4. Data block retrieval via inode pointers.

Linux caches frequent accesses to optimize performance.

5. Common File Systems: Choosing Your “Manager”

File SystemBest ForKey Features
ext4General useStable, supports 16TB files, 1EB partitions
XFSDatabases/cloudEfficient with small files
BtrfsAdvanced featuresSnapshots, compression (less stable)
FATUSB drivesCross-platform compatibility
swapVirtual memory2× RAM size (typically)

Example: Use XFS for databases on a Hong Kong server for better small-file performance.

6. Hands-On: Building a File System

6.1 Check New Disk (/dev/sdb)

bash
ls /dev/sd*  # Output: /dev/sda /dev/sda1 /dev/sda2 /dev/sdb

6.2 Partition with fdisk

bash
fdisk /dev/sdb

Steps:

  1. Press n (new partition), p (primary), default values.

  2. Set size (+1G for 1GB).

  3. Press w to save.

6.3 Format as ext4

bash
mkfs.ext4 /dev/sdb1

6.4 Mount & Use

bash
mkdir /mnt/mydisk
mount /dev/sdb1 /mnt/mydisk

7. Troubleshooting Tips

IssueDiagnostic CommandSolution
Mount failureblkidCheck UUID/formatting
Permission deniedls -l /mnt/mydiskchmod or chown
No space leftdf -h or df -iFree space/inodes

8. Special File Types

  • Hard Links: Multiple names, same inode (ln source target).

  • Soft Links: Shortcuts with own inodes (ln -s source target).

  • Pipes: IPC channels (ls | wc -l or mkfifo).

  • Device Files: Hardware interfaces (/dev/sda, /dev/tty).

Fun Fact: Deleting a hard link doesn’t erase data until the last link is gone!

9. Conclusion & Next Steps

The Linux file system is like a library:

  • VFS = Librarian

  • Inodes = Book catalog

  • Data Blocks = Actual books

To explore further:

  • Experiment with XFS/Btrfs on a Hong Kong server.

  • Trace system calls with strace.

  • Check out advanced tutorials on file system internals.

Ready to dive deeper? The world of Linux file systems awaits!

Recent Posts

  • CentOS End of Life (EOL): What It Means and Migration Options in 2026
  • How to Configure a LAMP Stack on CentOS Stream for Production
  • CentOS vs Ubuntu: Key Differences for Server Deployment in 2026
  • How to Install CentOS 9 Step-by-Step
  • What Is CentOS? A Complete Beginner’s Guide to CentOS Linux in 2026

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot