LFCA 36 🐧 Disks, Partitions, and Filesystems
Storage on Linux is organized in three layers. At the bottom is the disk — a physical device or its virtual equivalent, presented as a block device under /dev. On the disk is a partition table that divides the space into partitions. On each partition is a filesystem that tracks files, directories, permissions, and free space. Before a filesystem can be used, it must be mounted — attached to a directory in the tree. The root filesystem is mounted at /, and every other filesystem is mounted at some directory below it. This chapter covers the three layers, the naming scheme, the partition table formats, the filesystem types, and the mount model. It does not cover the commands for creating partitions or mounting them — those are the next chapters — but it covers the concepts that make those commands make sense.
Key point: A disk is a block device under /dev (/dev/sda, /dev/nvme0n1). A partition is a slice of the disk, named by appending a number to the disk name (/dev/sda1, /dev/nvme0n1p1). The partition table is either MBR (legacy, four primary partitions, 2 TB limit) or GPT (modern, 128 partitions, effectively unlimited size). Each partition is formatted with a filesystem — ext4, xfs, btrfs, zfs — before it can be used. The filesystem is mounted at a directory, and the mount point is where its contents appear. The /etc/fstab file declares the filesystems that mount at boot.
The disk
A disk is a block device. The kernel presents it as a file under /dev, and the file is the interface to the device. Reading and writing the file reads and writes the device.
The naming scheme. The traditional disk names are /dev/sda, /dev/sdb, /dev/sdc, and so on. The sd stands for SCSI disk, but the name is used for SATA, USB, and most other block devices. The letter after sd identifies the disk — a for the first, b for the second. NVMe disks use a different scheme: /dev/nvme0n1, /dev/nvme1n1, and so on, where the first number is the controller and the second is the namespace .
Why the names can change. The kernel assigns the names in the order the devices are detected. A disk that is /dev/sdb at one boot may be /dev/sdc at the next if another device is detected first. This is why the partition table and the /etc/fstab use UUIDs instead of device names — the UUID is stored in the filesystem and does not change .
The block device interface. The disk appears as a file, and the tools read and write it. The lsblk command lists the block devices in a tree, and the fdisk -l command lists the partition tables. The df -h command shows the mounted filesystems and their usage.
Why the disk is not the filesystem. The disk is the raw storage. The filesystem is the structure on top of it. A disk with no filesystem is a blank device; a disk with a filesystem is a usable storage area. The separation is the layering, and it is why a partition can be formatted with different filesystems.
Why the disk can be used without partitions. A whole disk can be formatted with a filesystem and mounted directly, without any partition table. This is common for some virtual disks and for the devices that are not meant to be partitioned. The partition table is the convention, not a requirement.
Partitions
A partition is a slice of the disk. The partition table records where each partition starts and ends, and the kernel presents each partition as its own block device.
The partition naming. A partition is named by appending a number to the disk name. /dev/sda1 is the first partition on /dev/sda, /dev/sda2 is the second. For NVMe disks, the separator is a p: /dev/nvme0n1p1, /dev/nvme0n1p2 .
Why partitions exist. A disk can be divided into several partitions, each with its own filesystem. This allows the root filesystem, the home directories, the swap space, and the boot files to be separate. The separation is for organization, for security, and for the ability to resize or replace one filesystem without affecting the others.
The MBR format. The Master Boot Record is the legacy partition table. It stores the partition information in the first sector of the disk. The limitations are significant: only four primary partitions, or three primary plus one extended partition that holds logical partitions; and a maximum partition size of 2 TB . The MBR is still used on older systems and on disks that must be compatible with them.
The GPT format. The GUID Partition Table is the modern format. It stores the partition information in a header that is replicated at the start and the end of the disk. The limits are much larger: 128 primary partitions by default, and partitions up to 9.4 ZB . GPT is the default on modern systems, and it is required for disks larger than 2 TB.
Why the choice matters. The MBR is simpler and more compatible. The GPT is more capable and is the modern standard. A new disk should use GPT unless there is a specific reason to use MBR. The parted tool creates GPT partitions, and the fdisk tool creates MBR partitions by default .
Why the partition table is read at boot. The kernel reads the partition table when the disk is detected and presents the partitions as block devices. The blockdev --rereadpt command forces a re-read after the table is changed, and the partprobe command does the same for the running kernel .
Filesystems
A filesystem is the structure on a partition that tracks files, directories, permissions, and free space. It is created with the mkfs command, and it is mounted to be used.
The inode. Every filesystem has an inode for each file and directory. The inode is the metadata record: ownership, permissions, timestamps, size, and pointers to the data blocks. The filename lives in the directory; the inode is the object the kernel works with. A filesystem is created with a fixed number of inodes, and it can run out of inodes even when there is free space — a common problem with millions of tiny files .
ext4. The fourth Extended Filesystem is the default on most Linux distributions. It is mature, well-understood, and supports journaling, extents, and delayed allocation. It supports file sizes up to 16 TB and filesystem sizes up to 1 EiB. It is the general-purpose choice, and it is the safe default when there is no specific reason to choose another .
XFS. XFS is optimized for large files and parallel I/O. It supports file sizes up to 500 TB and filesystem sizes up to 8 EiB. It is the default on RHEL and its derivatives, and it is a good choice for servers with large files and high throughput. It cannot be shrunk, which is a limitation to plan for .
Btrfs. Btrfs is a modern filesystem with copy-on-write, snapshots, checksums, and self-healing. It is the default on openSUSE and Fedora Workstation. It is more feature-rich than ext4, but it has more overhead and is considered less mature for some RAID configurations .
ZFS. ZFS is a high-performance filesystem with end-to-end checksums, snapshots, clones, and integrated volume management. It is licensed under the CDDL, so it is packaged separately from the kernel. It is used in enterprise and NAS environments .
Why the choice matters. The filesystem determines the performance, the features, and the limits. ext4 is the general-purpose default. XFS is for large files and high throughput. Btrfs is for snapshots and data integrity. ZFS is for the enterprise features. The choice should match the workload.
Why the filesystem must be mounted. A filesystem that is not mounted is not accessible. The mount command attaches it to a directory, and the contents appear at that directory. The mount point is the directory, and it must exist before the mount .
Mounting
Mounting is the act of attaching a filesystem to a directory. The directory is the mount point, and after the mount, the filesystem’s contents appear at that directory.
The mount point. The mount point is an existing directory. After the mount, the directory is the root of the filesystem. Anything that was in the directory before the mount is hidden — it is still there, but it is not visible until the filesystem is unmounted .
The root filesystem. The root filesystem is mounted at /. It contains the core operating system. Every other filesystem is mounted at some directory below /, and the tree is the union of all the mounted filesystems.
Why the separation. A separate /home filesystem allows the user’s files to survive a reinstall of the operating system. A separate /var filesystem allows the logs and the databases to grow without filling the root. A separate /boot filesystem holds the kernel and the bootloader. The separation is for organization, for stability, and for the ability to manage the space independently .
The /etc/fstab file. The filesystem table declares the filesystems that mount at boot. Each line has six fields: the device or UUID, the mount point, the filesystem type, the mount options, the dump flag, and the fsck order. The file is read at boot, and the entries are mounted in order .
Why UUIDs are used. The device name can change between boots. The UUID is stored in the filesystem and does not change. The /etc/fstab uses the UUID to identify the filesystem reliably .
Why the mount options matter. The options control the behavior: defaults uses the standard settings; ro mounts read-only; noatime reduces the writes by not updating the access time; user allows a non-root user to mount the filesystem. The options are the fine-grained control .
Why the mount can fail. A wrong UUID, a wrong filesystem type, or a missing mount point causes the mount to fail. If the entry is in /etc/fstab, the failure can delay or prevent the boot. The mount -a command tests the entries without rebooting, and it is the safe way to verify a change .
Complete Example Session
# ============================================
# PART 1: LIST THE BLOCK DEVICES
# ============================================
lsblk
# NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
# sda 8:0 0 500G 0 disk
# ├─sda1 8:1 0 512M 0 part /boot/efi
# ├─sda2 8:2 0 100G 0 part /
# └─sda3 8:3 0 399G 0 part /home
# ============================================
# PART 2: VIEW THE PARTITION TABLE
# ============================================
sudo fdisk -l /dev/sda
# Disk /dev/sda: 500 GiB, 536870912000 bytes, 1048576000 sectors
# Disk model: ...
# Disklabel type: gpt
# Disk identifier: ...
#
# Device Start End Sectors Size Type
# /dev/sda1 2048 1050623 1048576 512M EFI System
# /dev/sda2 1050624 210763775 209713152 100G Linux filesystem
# /dev/sda3 210763776 1048575999 837812224 399G Linux filesystem
# ============================================
# PART 3: VIEW THE FILESYSTEM TYPES
# ============================================
df -T
# Filesystem Type 1K-blocks Used Available Use% Mounted on
# /dev/sda2 ext4 102400000 5000000 95000000 5% /
# /dev/sda3 ext4 409600000 1000000 400000000 1% /home
# /dev/sda1 vfat 523248 5000 518248 1% /boot/efi
# ============================================
# PART 4: VIEW THE UUIDs
# ============================================
sudo blkid
# /dev/sda1: UUID="A1B2-C3D4" TYPE="vfat" PARTUUID="..."
# /dev/sda2: UUID="1234abcd-..." TYPE="ext4" PARTUUID="..."
# /dev/sda3: UUID="5678efgh-..." TYPE="ext4" PARTUUID="..."
# ============================================
# PART 5: THE /etc/fstab FILE
# ============================================
cat /etc/fstab
# UUID=1234abcd-... / ext4 defaults 0 1
# UUID=5678efgh-... /home ext4 defaults 0 2
# UUID=A1B2-C3D4 /boot/efi vfat defaults 0 2
# ============================================
# PART 6: THE MOUNT POINTS
# ============================================
mount | grep sda
# /dev/sda2 on / type ext4 (rw,relatime)
# /dev/sda3 on /home type ext4 (rw,relatime)
# /dev/sda1 on /boot/efi type vfat (rw,relatime)
# ============================================
# PART 7: THE INODE USAGE
# ============================================
df -i
# Filesystem Inodes IUsed IFree IUse% Mounted on
# /dev/sda2 6400000 100000 6300000 2% /
# /dev/sda3 25600000 500000 25100000 2% /home
# ============================================
# PART 8: THE DISK LAYERS
# ============================================
# Layer 1: DISK
# /dev/sda — the block device
#
# Layer 2: PARTITION TABLE
# GPT, recorded in the disk's header
# /dev/sda1, /dev/sda2, /dev/sda3 — the partitions
#
# Layer 3: FILESYSTEM
# ext4 on /dev/sda2, ext4 on /dev/sda3, vfat on /dev/sda1
#
# Layer 4: MOUNT
# /dev/sda2 mounted at /, /dev/sda3 at /home, /dev/sda1 at /boot/efi
# ============================================
# PART 9: WHAT NOT TO DO
# ============================================
# Don't use /dev/sdX in fstab
# The device name can change. Use UUID.
# Don't assume a disk with no filesystem is usable
# It must be formatted and mounted.
# Don't mount a filesystem at a non-empty directory
# The existing contents are hidden.
# Don't edit fstab without testing
# mount -a verifies the entries.
# Don't assume the disk is the filesystem
# The disk is the raw storage; the filesystem is the structure.
The nine parts cover the block devices, the partition table, the filesystem types, the UUIDs, the fstab, the mount points, the inodes, the layers, and the anti-patterns.
Quick Reference
The Layers
| Layer | Example | Purpose |
|---|---|---|
| Disk | /dev/sda | The block device |
| Partition table | GPT or MBR | Divides the disk |
| Partition | /dev/sda1 | A slice of the disk |
| Filesystem | ext4, xfs | Tracks files and space |
| Mount | /, /home | Attaches to the tree |
The Naming Scheme
| Device | Example |
|---|---|
| SATA/SCSI disk | /dev/sda, /dev/sdb |
| SATA/SCSI partition | /dev/sda1, /dev/sda2 |
| NVMe disk | /dev/nvme0n1 |
| NVMe partition | /dev/nvme0n1p1 |
The Partition Table Formats
| Format | Partitions | Max Size | Tool |
|---|---|---|---|
| MBR | 4 primary | 2 TB | fdisk |
| GPT | 128 | 9.4 ZB | parted, gdisk |
The Filesystems
| Filesystem | Default On | Best For |
|---|---|---|
| ext4 | Most distros | General purpose |
| XFS | RHEL | Large files, parallel I/O |
| Btrfs | openSUSE, Fedora | Snapshots, integrity |
| ZFS | — | Enterprise, NAS |
The /etc/fstab Fields
| Field | Example | Purpose |
|---|---|---|
| Device | UUID=... | The filesystem |
| Mount point | /home | Where to mount |
| Type | ext4 | The filesystem type |
| Options | defaults | Mount options |
| Dump | 0 | Backup flag |
| Pass | 2 | fsck order |
The Commands
| Command | Purpose |
|---|---|
lsblk | List block devices |
fdisk -l | List partitions |
df -h | Disk usage |
df -i | Inode usage |
blkid | UUIDs and types |
mount | Mount a filesystem |
umount | Unmount |
Best Practices
✅ Do This:
# Use UUIDs in fstab
UUID=1234abcd-... /home ext4 defaults 0 2 # ✅
# Verify the fstab with mount -a before rebooting
sudo mount -a # ✅
# Use GPT for modern disks
sudo parted /dev/sdb mklabel gpt # ✅
# Check the inode usage on a filesystem with many small files
df -i # ✅
# Use XFS for large files and parallel I/O
sudo mkfs.xfs /dev/sdb1 # ✅
# Use ext4 for general-purpose workloads
sudo mkfs.ext4 /dev/sdb1 # ✅
❌ Don’t Do This:
# Don't use the device name in fstab
/dev/sdb1 /home ext4 defaults 0 2 # name can change # ⚠️
# Don't mount at a non-empty directory without knowing
# The existing contents are hidden. # ⚠️
# Don't assume a disk is usable without a filesystem
# It must be formatted and mounted. # ⚠️
# Don't use MBR for a disk larger than 2 TB
# The partition cannot exceed the limit. # ⚠️
# Don't edit fstab without testing
# A wrong entry can break the boot. # ⚠️
Common Pitfalls
| Pitfall | Problem | Solution |
|---|---|---|
| Device name in fstab | Mount fails after hardware change | Use UUID |
| No filesystem on the partition | Not usable | mkfs |
| Mount point not empty | Existing contents hidden | Use an empty directory |
| Wrong filesystem type | Mount fails | Check with blkid |
| Inodes exhausted | Cannot create files | df -i |
| MBR on a large disk | Partition limit | Use GPT |
| fstab not tested | Boot failure | mount -a |
Real-World Examples
1. List the disks
lsblk
2. View the partitions
sudo fdisk -l /dev/sda
3. View the filesystem types
df -T
4. View the UUIDs
sudo blkid
5. View the fstab
cat /etc/fstab
6. View the mounts
mount | grep sda
7. Check the inode usage
df -i
8. Create a GPT partition table
sudo parted /dev/sdb mklabel gpt
9. Format with ext4
sudo mkfs.ext4 /dev/sdb1
10. Test the fstab
sudo mount -a
Visual: The Storage Layers
┌──────────────────────────────────────────────────────────┐
│ DISK │
│ /dev/sda — the block device │
│ │
├──────────────────────────────────────────────────────────┤
│ PARTITION TABLE │
│ GPT or MBR, stored in the disk's header │
│ │
├──────────────────────────────────────────────────────────┤
│ PARTITIONS │
│ /dev/sda1, /dev/sda2, /dev/sda3 │
│ │
├──────────────────────────────────────────────────────────┤
│ FILESYSTEMS │
│ ext4 on sda2, ext4 on sda3, vfat on sda1 │
│ │
├──────────────────────────────────────────────────────────┤
│ MOUNTS │
│ sda2 at /, sda3 at /home, sda1 at /boot/efi │
│ │
│ Each layer builds on the one below it. │
│ │
└──────────────────────────────────────────────────────────┘
Visual: MBR vs GPT
┌──────────────────────────────────────────────────────────┐
│ MBR │
│ 4 primary partitions, or │
│ 3 primary + 1 extended (with logical partitions) │
│ Max partition size: 2 TB │
│ Stored in the first sector │
│ │
├──────────────────────────────────────────────────────────┤
│ GPT │
│ 128 primary partitions by default │
│ Max partition size: 9.4 ZB │
│ Stored at the start and end of the disk │
│ Redundant and checksummed │
│ │
│ GPT is the modern default. │
│ │
└──────────────────────────────────────────────────────────┘
Visual: The Mount Model
┌──────────────────────────────────────────────────────────┐
│ / (root) │
│ │ │
│ ├── /boot/efi ← mounted from /dev/sda1 (vfat) │
│ │ │
│ ├── /home ← mounted from /dev/sda3 (ext4) │
│ │ │
│ ├── /var ← mounted from /dev/sdb1 (xfs) │
│ │ │
│ └── /mnt/data ← mounted from /dev/sdc1 (ext4) │
│ │
│ The tree is the union of all the mounted filesystems. │
│ Each mount point is the root of its filesystem. │
│ │
└──────────────────────────────────────────────────────────┘
Visual: The fstab
┌──────────────────────────────────────────────────────────┐
│ UUID=1234abcd-... / ext4 defaults 0 1 │
│ UUID=5678efgh-... /home ext4 defaults 0 2 │
│ UUID=A1B2-C3D4 /boot/efi vfat defaults 0 2 │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ └── fsck order│
│ │ │ │ │ └── dump flag │
│ │ │ │ └── mount options │
│ │ │ └── filesystem type │
│ │ └── mount point │
│ └── device (UUID) │
│ │
│ Six fields per line. Read at boot. │
│ │
└──────────────────────────────────────────────────────────┘
Visual: The Filesystem Choice
┌──────────────────────────────────────────────────────────┐
│ General purpose? │
│ └── ext4 │
│ │
│ Large files, high throughput? │
│ └── XFS │
│ │
│ Snapshots, data integrity? │
│ └── Btrfs │
│ │
│ Enterprise, NAS, maximum features? │
│ └── ZFS │
│ │
│ The choice matches the workload. │
│ │
└──────────────────────────────────────────────────────────┘
Summary
| Layer | Example | Purpose |
|---|---|---|
| Disk | /dev/sda | Block device |
| Partition table | GPT, MBR | Divides the disk |
| Partition | /dev/sda1 | Slice of the disk |
| Filesystem | ext4, xfs | Tracks files and space |
| Mount | /, /home | Attaches to the tree |
| Format | Partitions | Max Size |
|---|---|---|
| MBR | 4 primary | 2 TB |
| GPT | 128 | 9.4 ZB |
| Filesystem | Default On | Best For |
|---|---|---|
| ext4 | Most distros | General purpose |
| XFS | RHEL | Large files |
| Btrfs | openSUSE, Fedora | Snapshots |
| ZFS | — | Enterprise |
Key takeaways:
- Storage on Linux is three layers: the disk, the partitions, and the filesystems — each layer builds on the one below it, and the filesystem must be mounted to be used
- A disk is a block device under
/dev— the naming scheme is/dev/sda,/dev/sdb, and the partitions append a number (/dev/sda1) - The partition table is MBR or GPT — MBR is the legacy with a 2 TB limit and four primary partitions; GPT is the modern with 128 partitions and effectively unlimited size
- A filesystem tracks files, directories, permissions, and free space — the inode is the metadata record, and a filesystem can run out of inodes even with free space
- ext4 is the general-purpose default — XFS is for large files and parallel I/O, Btrfs for snapshots and integrity, ZFS for enterprise features
- Mounting attaches a filesystem to a directory — the directory is the mount point, and the contents appear at that directory
- The
/etc/fstabfile declares the filesystems that mount at boot — the six fields are the device, the mount point, the type, the options, the dump flag, and the fsck order - UUIDs are used instead of device names — the device name can change between boots, and the UUID is stored in the filesystem
- The mount options control the behavior —
defaults,ro,noatime,userare the common ones - A wrong fstab entry can break the boot — the
mount -acommand tests the entries without rebooting, and it is the safe way to verify a change
Remember: Storage is layered. The disk is the raw device, the partition table divides it, the partitions are the slices, the filesystems are the structures, and the mounts attach them to the tree. The filesystem choice matches the workload, the partition table format matches the disk size, and the fstab uses the UUID to identify the filesystem reliably. The next chapters cover the commands for creating the partitions and mounting the filesystems.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!