6. Create and Configure File Systems
πRed Hat Certified System Administrator (RHCSA β EX200)
1. What is a File System?
A file system is the way an operating system organizes, stores, and retrieves data on storage devices (like hard drives, SSDs, USB drives).
- Without a file system, the OS cannot understand where files are or how to access them.
- Common Linux file systems include:
- VFAT β Compatible with Windows and Linux (good for USB drives).
- ext4 β Standard Linux file system, reliable, fast, and supports large files.
- XFS β High-performance file system, used for big data and fast storage.
2. Creating a File System
Before creating a file system, you need a partition or a logical volume. The command to create a file system depends on the type:
a) VFAT
- Compatible with both Linux and Windows.
- Used on USB drives or small partitions for cross-platform sharing.
- Command:
sudo mkfs.vfat /dev/sdb1
/dev/sdb1is the partition you want to format.
b) ext4
- Default Linux file system.
- Good for general-purpose Linux storage.
- Command:
sudo mkfs.ext4 /dev/sdb1
c) XFS
- High-performance, great for large files and enterprise storage.
- Command:
sudo mkfs.xfs /dev/sdb1
Tip for exams: Know the correct mkfs command for each file system type.
3. Mounting File Systems
Mounting connects a storage device to the Linux filesystem so you can access its files.
- Linux uses mount points (empty directories) to attach file systems.
- Example mount points:
/mnt/usb,/data,/backup.
Command Syntax
sudo mount -t <type> <device> <mount_point>
Examples
- Mount VFAT USB drive:
sudo mount -t vfat /dev/sdb1 /mnt/usb
- Mount ext4 partition:
sudo mount -t ext4 /dev/sdb1 /data
- Mount XFS partition:
sudo mount -t xfs /dev/sdb1 /backup
Important:
- If you donβt specify
-t, Linux tries to auto-detect the file system.
4. Unmounting File Systems
Unmounting safely disconnects the file system from the OS.
- Always unmount before removing a device to avoid data loss.
Command
sudo umount <mount_point_or_device>
Examples
sudo umount /mnt/usb
sudo umount /dev/sdb1
Exam Tip: umount is without an βnβ in Linux β a common trick question.
5. Using File Systems
Once mounted, you can use the file system like any folder:
- List files:
ls -l /mnt/usb
- Create files:
touch /mnt/usb/testfile.txt
- Copy files:
cp /data/report.txt /backup/
- Check disk usage:
df -h
- Check free space on mounted file systems:
du -sh /mnt/usb
IT Environment Context:
- VFAT: Sharing configuration files between Windows and Linux servers.
- ext4: Storing application logs, system files, or user data.
- XFS: Large database storage or high-performance file servers.
6. Automount at Boot (Optional but Useful)
To make a file system automatically mount at boot, add an entry to /etc/fstab:
/dev/sdb1 /data ext4 defaults 0 2
- Fields:
device,mount_point,file_system_type,options,dump,fsck. - Ensures file systems are ready automatically after reboot.
7. Key Exam Points to Remember
- VFAT = compatible with Windows and Linux.
- ext4 = default Linux file system, reliable.
- XFS = high-performance, best for large data.
- Creating a file system β
mkfs.<type> /dev/<device> - Mounting β
mount -t <type> <device> <mount_point> - Unmounting β
umount <mount_point> - Check usage β
df -handdu -sh <folder> - Automount β
/etc/fstab
β
Summary:
You now know how to create, mount, unmount, and use VFAT, ext4, and XFS file systems. Remember the commands and the purpose of each type for the exam. Being confident with these commands ensures you can handle storage tasks in Linux environments.
