Skip to content

Linux Filesystem Management

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux Filesystem Management Guide

Complete beginner-friendly guide to managing filesystems on Linux, covering Arch Linux, CachyOS, and other distributions including ext4, btrfs, xfs, mounting, formatting, and filesystem optimization.


Table of Contents

  1. Understanding Filesystems
  2. Common Filesystems
  3. Creating Filesystems
  4. Mounting Filesystems
  5. fstab Configuration
  6. Filesystem Maintenance
  7. Filesystem Optimization
  8. Troubleshooting

Understanding Filesystems

What is a Filesystem?

Filesystem organizes how data is stored on disk.

What it does:

  • Organizes files: Structures file storage
  • Manages space: Tracks used/free space
  • File metadata: Stores file information
  • Access control: Manages permissions

Why it matters:

  • Performance: Affects disk performance
  • Features: Different features per filesystem
  • Reliability: Data integrity
  • Compatibility: System compatibility

Common Filesystems

ext4

ext4 is the default Linux filesystem.

Features:

  • Mature: Stable and well-tested
  • Compatible: Works everywhere
  • Reliable: Good data integrity
  • Performance: Good performance

Best for:

  • General use: Most use cases
  • Stability: When reliability matters
  • Compatibility: Maximum compatibility

btrfs

btrfs is a modern filesystem.

Features:

  • Snapshots: System snapshots
  • Compression: Built-in compression
  • RAID: Software RAID support
  • Copy-on-write: Efficient storage

Best for:

  • Snapshots: System snapshots
  • Advanced features: Modern features
  • Storage efficiency: Compression

See Btrfs Guide for detailed guide.

xfs

xfs is a high-performance filesystem.

Features:

  • Performance: High performance
  • Large files: Handles large files well
  • Scalability: Scales well
  • Journaling: Reliable journaling

Best for:

  • Performance: High-performance needs
  • Large files: Large file storage
  • Servers: Server environments

Creating Filesystems

Format as ext4

Create ext4:

# Format partition
sudo mkfs.ext4 /dev/sda1

# With label
sudo mkfs.ext4 -L "MyData" /dev/sda1

Format as btrfs

Create btrfs:

# Format as btrfs
sudo mkfs.btrfs /dev/sda1

# With label
sudo mkfs.btrfs -L "MyData" /dev/sda1

Format as xfs

Create xfs:

# Format as xfs
sudo mkfs.xfs /dev/sda1

# With label
sudo mkfs.xfs -L "MyData" /dev/sda1

Mounting Filesystems

Manual Mount

Mount filesystem:

# Create mount point
sudo mkdir /mnt/data

# Mount
sudo mount /dev/sda1 /mnt/data

# Check
df -h

Unmount

Unmount:

# Unmount
sudo umount /mnt/data

# Or
sudo umount /dev/sda1

fstab Configuration

Edit fstab

Edit fstab:

# Edit fstab
sudo vim /etc/fstab

Example entry:

UUID=xxxx-xxxx  /mnt/data  ext4  defaults  0  2

Fields:

  1. Device: UUID or device path
  2. Mount point: Where to mount
  3. Filesystem: Filesystem type
  4. Options: Mount options
  5. Dump: Backup flag (0 or 1)
  6. Pass: fsck order (0, 1, or 2)

Find UUID

Get UUID:

# List UUIDs
lsblk -f

# Or
blkid

Filesystem Maintenance

Check Filesystem

Check ext4:

# Check filesystem
sudo fsck.ext4 /dev/sda1

# Auto-repair
sudo fsck.ext4 -a /dev/sda1

Check btrfs:

# Check btrfs
sudo btrfs check /dev/sda1

# Scrub
sudo btrfs scrub start /mnt/data

Resize Filesystem

Resize ext4:

# Extend
sudo resize2fs /dev/sda1

# Resize to specific size
sudo resize2fs /dev/sda1 20G

Resize btrfs:

# Extend
sudo btrfs filesystem resize +10G /mnt/data

# Resize to specific size
sudo btrfs filesystem resize 20G /mnt/data

Filesystem Optimization

ext4 Optimization

Mount options:

# Edit fstab
sudo vim /etc/fstab

Optimized options:

UUID=xxxx-xxxx  /  ext4  defaults,noatime,commit=60  0  1

Options:

  • noatime: Don't update access times
  • commit=60: Commit every 60 seconds

btrfs Optimization

Enable compression:

# Mount with compression
sudo mount -o compress=zstd /dev/sda1 /mnt/data

# Or in fstab
UUID=xxxx-xxxx  /mnt/data  btrfs  defaults,compress=zstd  0  2

Troubleshooting

Mount Errors

Check filesystem:

# Check filesystem
sudo fsck.ext4 /dev/sda1

# Check mount options
mount | grep /dev/sda1

Permission Issues

Fix permissions:

# Change ownership
sudo chown -R user:group /mnt/data

# Fix permissions
sudo chmod -R 755 /mnt/data

Summary

This guide covered filesystem management for Arch Linux, CachyOS, and other distributions, including ext4, btrfs, xfs, mounting, and optimization.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally