Chapter 3.8 - Types of File Systems
Learning Objectives
By the end of this chapter, you will be able to:
- Understand the different types of file systems
- Identify common file systems
- Choose the right file system for the case
- Understand special file systems
What is a File System?
A file system defines how data is organized and stored on a disk. Linux supports many types of file systems.
Local File Systems
ext4 (Fourth Extended)
The most common on Linux:
Features:
- Journaled: Crash-resistant
- Max size: 1EB (exabyte)
- Max file: 16TB
- Stable and mature
Usage:
- Default file system
- Local disks
- General-purpose servers
Commands:
# Create
mkfs.ext4 /dev/sda1
# Check
fsck.ext4 /dev/sda1
# View info
tune2fs -l /dev/sda1
xfs
High performance for large files:
Features:
- Very high performance for large files
- Max size: 8EB
- Max file: 8EB
- Dynamic allocation
Usage:
- Databases
- Large files
- High-performance servers
Commands:
# Create
mkfs.xfs /dev/sda1
# Check
xfs_repair /dev/sda1
# View info
xfs_info /dev/sda1
btrfs (B-Tree File System)
Advanced features:
Features:
- Snapshots: Instantaneous
- Compression: Transparent
- Copy-on-Write: Efficient
- Integrated RAID
Usage:
- Systems requiring snapshots
- Backups
- Development environments
Commands:
# Create
mkfs.btrfs /dev/sda1
# Create a snapshot
btrfs subvolume snapshot /mnt/data /mnt/data/snapshot1
# Compression
mount -o compress=zlib /dev/sda1 /mnt
Comparison
| FS | Max Size | Max File | Journal | Usage |
|---|---|---|---|---|
| ext4 | 1EB | 16TB | Yes | General |
| xfs | 8EB | 8EB | Yes | Large files |
| btrfs | 16EB | 16EB | Yes | Advanced |
Network File Systems
NFS (Network File System)
File sharing over network:
# Server: Export
# /etc/exports
/home/user1 192.168.1.0/24(rw,sync)
# Client: Mount
mount -t nfs server:/home/user1 /mnt/nfs
Usage:
- File sharing between Unix/Linux systems
- Centralized file servers
CIFS/SMB
Windows compatible:
# Mount a Windows share
mount -t cifs //server/share /mnt/smb -o username=user
Usage:
- Cross-platform sharing
- Windows compatibility
Special File Systems
tmpfs
In-memory (RAM):
# Mount tmpfs
mount -t tmpfs -o size=1G tmpfs /mnt/tmpfs
# Used for:
# - /tmp (often)
# - /dev/shm (shared memory)
Features:
- Very fast (RAM)
- Temporary (lost on reboot)
- Size limited by RAM
procfs
Interface to the kernel:
# Automatically mounted on /proc
# Contains:
# - /proc/cpuinfo: CPU info
# - /proc/meminfo: Memory info
# - /proc/pid/: Process details
Features:
- Virtual file system
- Real-time data
- Read-only (generally)
sysfs
System information:
# Automatically mounted on /sys
# Contains:
# - /sys/class/: Device classes
# - /sys/devices/: Devices
Features:
- Hardware interface
- Hardware configuration
- Virtual
Management Commands
View Mounted File Systems
# Simple list
mount
# Human-readable format
df -h
# File system types
mount | grep -E '^/dev' | awk '{print $5}' | sort -u
Mount/Unmount
# Mount
mount /dev/sda1 /mnt
mount -t ext4 /dev/sda1 /mnt
# Mount with options
mount -o rw,noexec /dev/sda1 /mnt
# Unmount
umount /mnt
umount /dev/sda1
# Force unmount (if busy)
umount -f /mnt
umount -l /mnt # Lazy unmount
Permanent Configuration (/etc/fstab)
# Format: device mountpoint fstype options dump pass
/dev/sda1 / ext4 defaults 0 1
/dev/sda2 /home ext4 defaults 0 2
/dev/sda3 /var xfs defaults 0 2
server:/export /mnt/nfs nfs defaults 0 0
Common options:
defaults: rw, suid, dev, exec, auto, nouser, asyncnoexec: No executionnosuid: Ignore SUIDro: Read-onlynoatime: No atime update
Verification and Repair
fsck
Check and repair:
# Check (without repair)
fsck /dev/sda1
# Automatically repair
fsck -a /dev/sda1
# Force check
fsck -f /dev/sda1
# Specific to ext4
fsck.ext4 /dev/sda1
Important:
- Unmount before fsck (if possible)
- Single-user mode for root system
Summary
In this chapter, you learned:
Local types: ext4 (standard), xfs (large files), btrfs (advanced)
Network types: NFS (Unix), CIFS/SMB (Windows)
Special types: tmpfs (RAM), procfs (kernel), sysfs (system)
Management: mount, umount, /etc/fstab for permanent mounting
Verification: fsck to repair file systems
Next Steps
Lab 3.4: Complete Practice
Module 4: Process Management
Chapter created on: December 2024