Linux File System Types and Management on AlmaLinux
Categories:
4 minute read
Bob’s manager tasked him with organizing and managing the server’s storage effectively. To do so, Bob needed to understand the Linux file system, its types, and how to manage partitions, mounts, and attributes.
“The file system is the skeleton of my server—it’s time to learn every bone!” Bob declared as he dove into this essential topic.
Chapter Outline: “Bob Explores Linux File System Types and Management”
Introduction: Why File Systems Matter
- Overview of Linux file system types and their use cases.
- Exploring the File Hierarchy Standard (FHS).
Understanding File System Types
- Popular Linux file systems: ext4, xfs, btrfs, etc.
- When to choose each file system.
Creating and Managing Partitions
- Partitioning a disk with
fdiskandparted. - Formatting partitions with
mkfs.
- Partitioning a disk with
Mounting and Unmounting File Systems
- Temporary mounting with
mount. - Persistent mounts with
/etc/fstab.
- Temporary mounting with
Exploring Advanced File System Features
- File attributes with
lsattrandchattr. - Managing quotas and permissions.
- File attributes with
Monitoring and Maintaining File Systems
- Checking usage with
dfanddu. - Repairing file systems with
fsck.
- Checking usage with
Conclusion: Bob Reflects on File System Mastery
Part 1: Introduction: Why File Systems Matter
Bob learned that the file system is the structure used by an operating system to organize and store files on a disk. A well-maintained file system ensures data reliability, security, and performance.
Key Concepts
- File Hierarchy Standard (FHS): Defines the standard layout of directories (e.g.,
/home,/var,/etc). - Mount Points: Locations where file systems are made accessible (e.g.,
/mnt/data).
“A well-organized file system is like a clean desk—everything is where it should be!” Bob thought.
Part 2: Understanding File System Types
Bob explored the most common file systems used on Linux:
Popular Linux File Systems
- ext4:
- Default file system for many Linux distributions.
- Reliable and widely supported.
- xfs:
- High-performance file system, especially for large files.
- Default in AlmaLinux for
/partitions.
- btrfs:
- Advanced features like snapshots and compression.
- Ideal for modern systems requiring scalability.
Choosing a File System
- ext4 for general-purpose servers.
- xfs for high-performance workloads.
- btrfs for advanced features like snapshots.
“Each file system has its strengths—pick the right tool for the job!” Bob said.
Part 3: Creating and Managing Partitions
Step 1: Partitioning a Disk with fdisk
Bob needed to create a new partition on a secondary disk (/dev/sdb).
Launch
fdisk:sudo fdisk /dev/sdbUse the following commands:
n: Create a new partition.p: Make it a primary partition.- Enter defaults for partition size.
w: Write changes to the disk.
Step 2: Formatting the Partition
After creating the partition, Bob formatted it with the ext4 file system:
Format the partition:
sudo mkfs.ext4 /dev/sdb1Verify the file system:
sudo blkid /dev/sdb1
“A clean, formatted partition is ready to use!” Bob said.
Part 4: Mounting and Unmounting File Systems
Step 1: Temporary Mounting
Bob mounted the new partition to a directory:
Create a mount point:
sudo mkdir /mnt/dataMount the partition:
sudo mount /dev/sdb1 /mnt/dataVerify the mount:
df -h | grep /mnt/data
Step 2: Persistent Mounts with /etc/fstab
To ensure the partition was mounted at boot, Bob edited /etc/fstab:
Find the UUID of the partition:
sudo blkid /dev/sdb1Add an entry to
/etc/fstab:UUID=your-uuid-here /mnt/data ext4 defaults 0 2Test the configuration:
sudo mount -a
“Persistent mounts make sure my file systems are always available!” Bob noted.
Part 5: Exploring Advanced File System Features
File Attributes with lsattr and chattr
Bob explored advanced file attributes:
List attributes of a file:
lsattr file.txtMake a file immutable (cannot be modified or deleted):
sudo chattr +i file.txt
“Immutability is great for protecting critical files!” Bob said.
Managing Quotas
Bob set quotas to limit disk usage for users:
Install quota tools:
sudo dnf install -y quotaEnable quotas on a file system by adding
usrquotaorgrpquotato/etc/fstab.Assign quotas to a user:
sudo edquota -u username
“Quotas prevent anyone from hogging resources!” Bob said.
Part 6: Monitoring and Maintaining File Systems
Checking Disk Usage
Bob monitored disk usage with:
dffor file system-level stats:df -hdufor directory-level stats:du -sh /var/log
Repairing File Systems with fsck
Bob used fsck to repair a corrupted file system:
Unmount the file system:
sudo umount /dev/sdb1Run
fsck:sudo fsck /dev/sdb1
“A healthy file system keeps everything running smoothly!” Bob said.
Conclusion: Bob Reflects on File System Mastery
By mastering file system management, Bob could now handle partitions, mounts, attributes, and maintenance with ease. His confidence as a sysadmin grew as he organized his server like a pro.
Next, Bob plans to explore Advanced Bash Scripting on AlmaLinux.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.