CachyOS Filesystem Management - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
CachyOS Filesystem Management Guide
Complete beginner-friendly guide to filesystem management on CachyOS, including ext4, btrfs, xfs, mounting, formatting, and filesystem optimization.
Table of Contents
- Understanding Filesystems
- Common Filesystems
- Formatting Disks
- Mounting Filesystems
- Filesystem Maintenance
- Filesystem Optimization
- 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
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: When speed matters
- Large files: Large file handling
- Servers: Server workloads
Other Filesystems
FAT32:
- Use: USB drives, compatibility
- Limitations: 4GB file size limit
NTFS:
- Use: Windows compatibility
- Features: Windows file system
exFAT:
- Use: Large USB drives
- Features: No file size limit
Formatting Disks
Check Disk
List disks:
lsblk
What this does:
- Lists block devices
- Shows disks and partitions
- Helps identify disk
Check disk details:
sudo fdisk -l
What this does:
- Shows detailed disk information
- Lists partitions
- Shows filesystem types
Format as ext4
Format partition:
sudo mkfs.ext4 /dev/sda1
What this does:
- Formats partition as ext4
- Creates ext4 filesystem
- ** Erases all data!**
With label:
sudo mkfs.ext4 -L "MyDisk" /dev/sda1
What this does:
- Formats with label
-L: Sets filesystem label- Easier identification
Format as btrfs
Format partition:
sudo mkfs.btrfs /dev/sda1
What this does:
- Formats partition as btrfs
- Creates btrfs filesystem
- ** Erases all data!**
With compression:
sudo mkfs.btrfs -f -L "MyDisk" /dev/sda1
What this does:
- Formats btrfs
-f: Force (overwrites existing)-L: Sets label
Format as xfs
Format partition:
sudo mkfs.xfs /dev/sda1
What this does:
- Formats partition as xfs
- Creates xfs filesystem
- ** Erases all data!**
Mounting Filesystems
Manual Mounting
Mount filesystem:
sudo mount /dev/sda1 /mnt
What this does:
- Mounts partition to /mnt
- Makes filesystem accessible
- Temporary mount
Unmount:
sudo umount /mnt
What this does:
- Unmounts filesystem
- Safely removes mount
- ** Don't unmount while in use**
Permanent Mounting
Edit fstab:
sudo nano /etc/fstab
Add entry:
UUID=xxxx-xxxx-xxxx /mnt ext4 defaults 0 2
What this means:
UUID: Partition UUID/mnt: Mount pointext4: Filesystem typedefaults: Mount options0 2: Dump and fsck options
Find UUID:
lsblk -f
What this does:
- Shows filesystem UUIDs
- Use UUID in fstab
- More reliable than device names
Test fstab:
sudo mount -a
What this does:
- Mounts all fstab entries
- Tests configuration
- Verifies fstab is correct
Filesystem Maintenance
Check Filesystem
Check ext4:
sudo fsck.ext4 /dev/sda1
What this does:
- Checks filesystem integrity
- Finds and fixes errors
- ** Unmount first!**
Check btrfs:
sudo btrfs check /dev/sda1
What this does:
- Checks btrfs filesystem
- Verifies integrity
- ** Read-only check**
Check xfs:
sudo xfs_repair /dev/sda1
What this does:
- Checks and repairs xfs
- Fixes filesystem issues
- ** Unmount first!**
Filesystem Information
Show filesystem info:
df -h
What this does:
- Shows filesystem usage
-h: Human-readable- Shows used/available space
Show inode usage:
df -i
What this does:
- Shows inode usage
- Helps identify inode issues
- Important for many small files
Filesystem Optimization
ext4 Optimization
Mount options:
sudo mount -o noatime /dev/sda1 /mnt
What this does:
noatime: Don't update access times- Reduces disk writes
- Better performance
Add to fstab:
UUID=xxxx /mnt ext4 defaults,noatime 0 2
btrfs Optimization
Enable compression:
sudo mount -o compress=zstd /dev/sda1 /mnt
What this does:
- Enables zstd compression
- Saves disk space
- Good performance
Add to fstab:
UUID=xxxx /mnt btrfs defaults,compress=zstd 0 0
xfs Optimization
xfs is optimized by default:
- Good performance out of the box
- Few optimizations needed
- Works well as-is
Troubleshooting
Filesystem Errors
Check filesystem:
sudo fsck.ext4 -f /dev/sda1
What this does:
- Forces filesystem check
- Finds and fixes errors
- ** Unmount first!**
Auto-repair:
sudo fsck.ext4 -y /dev/sda1
What this does:
- Auto-answers yes
- Automatically repairs
- ** Use carefully**
Mount Errors
Check mount point:
mountpoint /mnt
What this does:
- Checks if mount point is mounted
- Verifies mount status
- Helps troubleshoot
Check fstab:
sudo mount -a
What this does:
- Tests fstab entries
- Shows mount errors
- Helps fix fstab
Disk Space Issues
Check disk usage:
df -h
What this does:
- Shows filesystem usage
- Identifies full filesystems
- Helps manage space
Find large files:
du -h --max-depth=1 / | sort -hr
What this does:
- Shows directory sizes
- Identifies large directories
- Helps free space
Additional Resources
- Automount Disks Guide - Automatic mounting
- CachyOS System Maintenance - System maintenance
- Arch Linux Wiki - File Systems: https://wiki.archlinux.org/title/File_systems
Summary
This guide covered:
- Understanding filesystems - What filesystems are
- Common filesystems - ext4, btrfs, xfs
- Formatting disks - Creating filesystems
- Mounting filesystems - Manual and permanent mounting
- Filesystem maintenance - Checking and repairing
- Filesystem optimization - Performance tuning
- Troubleshooting - Common filesystem issues
Key Takeaways:
- ext4 is default and reliable
- btrfs offers advanced features
- xfs is high-performance
- Use UUIDs in fstab for reliability
- Check filesystems regularly
- Optimize mount options for performance
- Always unmount before checking/repairing
This guide is based on the CachyOS Wiki and Arch Linux Wiki and expanded with detailed explanations for beginners. For the most up-to-date filesystem information, always refer to the official documentation.