Mastering Basic Storage for RHCSA Exam

Objective

RHEL stands out as a powerful operating system utilized across servers, desktop and embedded systems. Mastering storage management is vital for both newcomers and experienced users alike. This guide provides a thorough overview to fundamentals of RHEL storage, covering aspects like file systems, partitioning, mounting and logical volume management. With a solid understanding, you'll learn to optimize disk usage, enhance system efficiency and secure your data. Our objective is to empower you with the core skills required to tackle complexities of RHEL Storage in the RHCSA exam.

Understanding Disk Partitioning

Disk partitioning is an essential step for managing storage on both hard drives and solid-state drives. It involves dividing a physical disk into separate sections called partitions each acting like an independent disk. This partitioning is beneficial for various applications:

  • Efficient File Management: Creating separate partitions for specific data types such as documents, media and backups helps keep your files organized and easily accessible.

  • Running Multiple Operating Systems: If your goal is to run various operating systems on the same computer, partitioning helps you to assign space for each system ensuring they run without interference.

  • Data Isolation: Creating a separate partition for critical data enhances security and simplifies backup processes.

Types of Disk Partitions

Type of Partition

Description

Primary Partitions

  • The main divisions of a disk that can be used to boot the operating system.

  • Key Features:

    • Maximum of four per disk

    • Hosts its own file system

    • Direct access by the operating system

Extended Partitions

  • Created within a primary partition to host logical partitions, allowing more than four partitions on a disk.

  • Key Features:

    • Serves as a container

    • Enables the creation of multiple logical partitions

Logical Partitions

  • Found within an extended partition, allowing the creation of additional partitions beyond the primary limit.

  • Key Features:

    • Function like primary partitions

    • Accessed through the extended partition

    • Offer flexibility for complex storage setups

File Systems and Their Importance

A file system defines how data is organized, stored, and retrieved on a partition. The choice of file system can significantly impact the performance, storage efficiency, and compatibility of a partition. Some commonly used file systems include:

  • ext4: The default file system for many Linux distributions, known for its reliability and performance.

  • NTFS: Commonly used in Windows environments, suitable for large files and providing advanced features like journaling.

  • FAT32: An older file system that offers broad compatibility across various operating systems but has limitations on file size.

Selecting the appropriate file system is essential based on your use case, as it affects how data is managed and the features available for that partition.

Logical Volume Management (LVM)

LVM (Logical Volume Manager) provides flexible management of disk drives and partitions. It allows users to easily resize logical volumes, create snapshots for data protection and combine multiple disks into a single logical volume. This flexibility simplifies storage management and enhances efficiency making it easier to adapt to changing storage needs.

Mount Points

Mount points are specific directories in RHEL where users can access additional file systems. The root directory, represented as '/', acts as the central starting point for all file systems. This structure enables users to expand their storage capabilities and manage different file systems effectively, making it easier to organize and access data.

Tools for Disk Partitioning in Linux

Linux provides a variety of tools for managing disk partitions, each catering to different needs and disk types:

  • fdisk

fdisk is a powerful command-line utility designed for the management of Master Boot Record (MBR) disks. It provides users with the ability to effortlessly create, delete and modify partitions This tool is ideal for users familiar with command-line interface and is widely utilized across numerous Linux distribution for disk management tasks.

 

fdisk

Use the following commands:

  • m: Help

  • n: Create a new partition

  • d: Delete a partition

  • p: Print the partition table

  • w: Write changes and exit

Replace /dev/nvme2n1 with your partition identifier.

  • parted

parted is a versatile partition management tool that supports both MBR and GPT disks. It provides a user-friendly command-line interface and additional features such as resizing partitions, creating file systems, and managing partition flags. parted is suitable for users who need a more comprehensive solution for partition management. 

Replace /dev/nvme2n1 with your partition identifier.

parted

3. Creating File Systems

Once you’ve partitioned your drive, the next step is to create a file system.

a. Using mkfs

  • The mkfs command is used to create a file system on a specified partition, preparing it for storing data.

  • Creates an ext4 file system on the specified partition

    • sudo mkfs.ext4 /dev/nvme2n1

  • Replace /dev/nvme2n1 with your partition identifier.

b. Choosing a File System

Select a file system based on your needs:

  • Use ext4 for general-purpose use.

  • Choose XFS for high-performance applications requiring large file handling.

  • Opt for Btrfs if you need advanced features like snapshots or RAID configurations.

Mounting File Systems

Mounting is the process of making a file system accessible at a certain point in the directory structure.

a. Temporary Mounting

  • To mount a file system temporarily, use:

    • sudo mount /dev/nvme2n1 /mnt

  • Replace /dev/nvme2n1 with your partition identifier.

b. Permanent Mounting

  • To ensure a file system is automatically mounted at boot, you need to modify the /etc/fstab file.

  • Open /etc/fstab:

    • sudo nano /etc/fstab

  • Add a line for your partition:

    • /dev/nvme2n1  /mnt  ext4  defaults  0  2

c. Understanding /etc/fstab Options

  • defaults: Utilizes default mount options, such as read/write permissions, for ease of use.

  • noauto: Prevents the file system from being automatically mounted at boot time, allowing manual mounting as needed.

  • user: Grants permission for non-root users to mount the file system, increasing accessibility.

Managing Storage with LVM

a. Installing LVM

  • Logical Volume Manager (LVM) allows for flexible disk management, enabling dynamic resizing and management of partitions.

  • If LVM isn’t installed, you can install it using your package manager. 

    • sudo yum install lvm2

b. Creating a Volume Group

  •  A volume group is a collection of physical volumes that can be allocated for logical volumes.

  • Create physical volumes:

      sudo pvcreate /dev/nvme2n1 /dev/nvme2n2

  • Creates a volume group named "myvg" that includes the specified physical volumes, consolidating them for management.

      sudo vgcreate myvg /dev/nvme2n1 /dev/nvme2n2

c. Creating Logical Volumes

  • Logical volumes are flexible partitions created within a volume group.

  •  Creates a logical volume named "mylv" with a size of 10 GB within the volume group "myvg.:

    • sudo lvcreate -n mylv -L 10G myvg

d. Formatting and Mounting LVs

  • Logical volumes must be formatted with a file system before they can be used for storing data.

  •  Formats the logical volume as an ext4 file system, preparing it for use:

    • sudo mkfs.ext4 /dev/myvg/mylv

  • Mounts the logical volume at the /mnt directory, making its contents accessible.

    • sudo mount /dev/myvg/mylv /mnt

e. Managing Logical Volumes

  •  LVM provides tools for managing logical volumes, including resizing and creating snapshots.

  • Resizes the logical volume by adding 5 GB to its current size, allowing for dynamic disk management:

      sudo lvresize -L +5G /dev/myvg/mylv

  • Creates a snapshot of the logical volume, allowing users to save the state of the volume for backup or recovery:

      sudo lvcreate -s -n mylv_snapshot -L 1G /dev/myvg/mylv

Monitoring Disk Usage

Keep an eye on your disk usage using commands like:

  • df -h: Displays file system disk space usage.

  • du -sh /path/to/directory: Shows disk usage of a specific directory.

  • lsblk: Lists all block devices, showing how storage is partitioned and mounted.

Conclusion

A thorough understanding of RHEL storage concepts is essential for successful system administration and for aspirants for the RHCSA exam. Whether it involves partitioning disks, setting up file systems, or leveraging LVM, these foundational skills will greatly enhance your RHEL experience. This guide prepares you to manage your storage confidently, ensuring optimal performance and enhanced security. For hands-on practice, sign-in in rhcsa.guru and perform lab "Manage Basic Storage", it will ensure that you have learnt the concept thoroughly.