-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux Filesystem Management
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.
- Understanding Filesystems
- Common Filesystems
- Creating Filesystems
- Mounting Filesystems
- fstab Configuration
- Filesystem Maintenance
- Filesystem Optimization
- Troubleshooting
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
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 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 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
Create ext4:
# Format partition
sudo mkfs.ext4 /dev/sda1
# With label
sudo mkfs.ext4 -L "MyData" /dev/sda1Create btrfs:
# Format as btrfs
sudo mkfs.btrfs /dev/sda1
# With label
sudo mkfs.btrfs -L "MyData" /dev/sda1Create xfs:
# Format as xfs
sudo mkfs.xfs /dev/sda1
# With label
sudo mkfs.xfs -L "MyData" /dev/sda1Mount filesystem:
# Create mount point
sudo mkdir /mnt/data
# Mount
sudo mount /dev/sda1 /mnt/data
# Check
df -hUnmount:
# Unmount
sudo umount /mnt/data
# Or
sudo umount /dev/sda1Edit fstab:
# Edit fstab
sudo vim /etc/fstabExample entry:
UUID=xxxx-xxxx /mnt/data ext4 defaults 0 2
Fields:
- Device: UUID or device path
- Mount point: Where to mount
- Filesystem: Filesystem type
- Options: Mount options
- Dump: Backup flag (0 or 1)
- Pass: fsck order (0, 1, or 2)
Get UUID:
# List UUIDs
lsblk -f
# Or
blkidCheck ext4:
# Check filesystem
sudo fsck.ext4 /dev/sda1
# Auto-repair
sudo fsck.ext4 -a /dev/sda1Check btrfs:
# Check btrfs
sudo btrfs check /dev/sda1
# Scrub
sudo btrfs scrub start /mnt/dataResize ext4:
# Extend
sudo resize2fs /dev/sda1
# Resize to specific size
sudo resize2fs /dev/sda1 20GResize btrfs:
# Extend
sudo btrfs filesystem resize +10G /mnt/data
# Resize to specific size
sudo btrfs filesystem resize 20G /mnt/dataMount options:
# Edit fstab
sudo vim /etc/fstabOptimized options:
UUID=xxxx-xxxx / ext4 defaults,noatime,commit=60 0 1
Options:
-
noatime: Don't update access times -
commit=60: Commit every 60 seconds
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 2Check filesystem:
# Check filesystem
sudo fsck.ext4 /dev/sda1
# Check mount options
mount | grep /dev/sda1Fix permissions:
# Change ownership
sudo chown -R user:group /mnt/data
# Fix permissions
sudo chmod -R 755 /mnt/dataThis guide covered filesystem management for Arch Linux, CachyOS, and other distributions, including ext4, btrfs, xfs, mounting, and optimization.
- Btrfs Guide - Btrfs detailed guide
- Disk Utilities - Disk tools
- Backup and Restore - Backups
- ArchWiki Filesystems: https://wiki.archlinux.org/title/File_systems
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.