Skip to main content
E
EmmaPrep.com
System ManagementMEDIUMVerified Curriculum26 min read

System Management

Interactive AI Tutor Study Mode
Ask questions, request worked examples, or test understanding.

Chapter 1

System Management

Course: Comptia Linux Xk0 006
Subject: Comptia Linux Xk0 006
Chapter: System Management


1. Disk Partitioning

Disk partitioning is the process of dividing a physical storage device into logical sections called partitions. Each partition can hold a filesystem or be used as raw storage (e.g., for swap, RAID, or LVM).

Why Partition Disks?

Partitioning is important when:

  • Installing or reinstalling an operating system
  • Adding and preparing a new disk
  • Setting up dual-boot environments (e.g., Linux and Windows)
  • Organizing the file system by separating directories like /home, /var, and /boot

Linux provides several command-line tools to create, delete, and manage partitions on block devices.

1. fdisk – Partition Table Editor for MBR Disks

fdisk is a menu-based partitioning tool for managing MBR (Master Boot Record) partition tables. It's suitable for older systems and disks smaller than 2 TB.

Key characteristics:

  • Supports MBR partition tables only
  • Limited to disks up to 2 TB
  • Interactive, simple to use

Basic usage:

bash

sudo fdisk /dev/sdX

Replace /dev/sdX with the disk device (e.g., /dev/sda, /dev/sdb).

Common commands inside fdisk:

  • m – Help
  • n – Create a new partition
  • d – Delete a partition
  • t – Change a partition type
  • p – Print current partition table
  • w – Write changes and exit
  • q – Quit without saving

Example:

Create a new partition:

bash

sudo fdisk /dev/sdb

Inside fdisk:

n  → new partition   w  → write changes

2. parted – GPT and MBR Partitioning Tool

parted is a more advanced tool that supports both MBR and GPT partition tables. It's ideal for modern systems, large disks, and automation.

Key characteristics:

  • Supports both GPT and MBR
  • Works with disks over 2 TB
  • Useful for UEFI systems
  • Can be scripted or used interactively

Basic usage:

bash

sudo parted /dev/sdX

Example – interactive:

bash

sudo parted /dev/sdb (parted) mklabel gpt (parted) mkpart primary ext4 0% 100% (parted) quit

Example – scripted:

bash

sudo parted -s /dev/sdb mklabel gpt mkpart primary ext4 0% 100%

3. partprobe – Notify Kernel of Partition Changes

After modifying a partition table, the kernel might not immediately detect the new layout. partprobe is used to inform the kernel of partition changes without rebooting.

Usage:

bash

sudo partprobe /dev/sdX

Real-World Scenario: Adding a 4 TB Disk to a Server

A system administrator adds a 4 TB disk (/dev/sdb) to a Linux server for storing large media files.

Step-by-step:

  • Identify the new disk: bash lsblk
  • Partition the disk using parted: bash sudo parted /dev/sdb (parted) mklabel gpt (parted) mkpart primary ext4 0% 100% (parted) quit
  • Refresh kernel partition table: bash sudo partprobe /dev/sdb
  • Format the new partition: bash sudo mkfs.ext4 /dev/sdb1
  • Mount the partition: bash sudo mkdir /mnt/media sudo mount /dev/sdb1 /mnt/media
  • Make the mount persistent: bash sudo nano /etc/fstab Add the following line: bash /dev/sdb1 /mnt/media ext4 defaults 0 2
  • Verify the mount: bash df -h /mnt/media

Tool Summary

| Tool | Table Type Support | Best for | Notes | | fdisk | MBR only | Legacy systems (< 2 TB) | Interactive and basic | | parted | GPT and MBR | Modern disks and scripting | UEFI-compatible and SSD-friendly | | partprobe | N/A (sync tool) | Kernel sync after changes | Avoids reboot after partitioning |

2. Mounting Local and Remote Devices

In Linux, mounting is the process of attaching a storage device or filesystem to a directory (mount point) so that its contents can be accessed. This can include local partitions, external USB drives, network shares, or even encrypted volumes.

1. The mount Command

mount is the fundamental Linux command used to manually mount filesystems.

Syntax:

bash

sudo mount [options] device mount_point

Common usage:

  • Mount a local partition: bash sudo mount /dev/sdb1 /mnt/data
  • Mount a USB drive:   bash sudo mount /dev/sdc1 /media/usb
  • Mount with a specific filesystem:   bash sudo mount -t ext4 /dev/sdb1 /mnt/data

Notes:

  • The mount point (e.g., /mnt/data) must exist beforehand.
  • To unmount, use: bash sudo umount /mnt/data

2. /etc/fstab – Persistent Mount Configuration

The /etc/fstab file defines filesystems that should be mounted automatically at boot.

Format:

php-template

<mount_point> <filesystem_type>

Example entry:

bash

/dev/sdb1 /mnt/data ext4 defaults 0 2

Special options:

  • defaults – Standard mount options (read-write, auto, etc.)
  • noauto – Do not mount automatically
  • user – Allow non-root users to mount
  • nfs, cifs, sshfs – Used for remote mounts

Tips:

  • Use UUID= or LABEL= instead of device names for reliability:   bash UUID=123e4567 /mnt/data ext4 defaults 0 2
  • Get UUIDs:   bash blkid

3. systemd.mount – Systemd-based Mount Units

Systemd can manage mounts using mount units, allowing more control, dependency tracking, and on-demand mounting.

Example: Create /etc/systemd/system/mnt-data.mount

The file name must reflect the mount point:

kotlin

/mnt/data → mnt-data.mount

Sample unit content:

ini

[Unit] Description=Mount data disk After=network.target

[Mount] What=/dev/sdb1 Where=/mnt/data Type=ext4 Options=defaults

[Install] WantedBy=multi-user.target

Enable and start the mount:

bash

sudo systemctl daemon-reload

sudo systemctl enable --now mnt-data.mount

Advantages:

  • Integrates with systemd boot process
  • Supports dependencies and on-demand mounts
  • Useful for advanced or automated deployments

4. LUKS – Linux Unified Key Setup (Encrypted Volumes)

LUKS is the standard for disk encryption in Linux, commonly used to encrypt local drives, external USBs, or partitions (e.g., /home).

Workflow:

  • Encrypt a partition:   bash CopyEdit sudo cryptsetup luksFormat /dev/sdb1
  • Open the encrypted device: bash sudo cryptsetup open /dev/sdb1 secure_data
  • Create a filesystem (first time only): bash sudo mkfs.ext4 /dev/mapper/secure_data
  • Mount it:   bash sudo mount /dev/mapper/secure_data /mnt/secure
  • Close the device when done: bash sudo cryptsetup close secure_data

Use case:

Protecting confidential data on a laptop, or securely transporting files on a USB stick.

5. Mounting External Devices (USB drives, SD cards, etc.)

External storage devices are usually detected and mounted automatically by desktop environments (GNOME, KDE, etc.), but can also be mounted manually in headless or server environments.

Steps to manually mount:

  • Insert the USB drive
  • Identify the device: bash lsblk
  • Mount it:   bash sudo mount /dev/sdc1 /media/usb

Make it read-only (e.g., for malware investigation):

bash

sudo mount -o ro /dev/sdc1 /media/usb

Summary Table

| Method | Use Case | Automatic | Notes | | mount | Manual mount of any device | No | Good for testing or temporary access | | /etc/fstab | Persistent mount at boot | Yes | Use UUIDs or labels for stable configuration | | systemd.mount | Managed mounts via systemd | Yes | Supports dependencies and conditions | | LUKS | Encrypted local/portable storage | No | Requires unlocking before use | | External devices | USB, SD card, external HDD/SSD | Yes (GUI) | Auto-mounted on desktop; manual for headless setups |

3. Filesystem Management in Linux

Different Linux filesystems offer unique capabilities such as journaling, snapshots, checksumming, and scalability. Managing filesystems typically involves creating, checking, resizing, repairing, and tuning them using tools specific to each type.

Linux supports multiple filesystems, each with its own management utilities. Below is an overview of commonly used filesystems and their toolsets.

1. XFS Filesystem Tools

XFS is a high-performance journaling filesystem designed for scalability and robustness, particularly suited for large files and large-capacity systems (multi-terabyte or petabyte-scale).

Common tools

| Command | Purpose | | mkfs.xfs | Create an XFS filesystem | | xfs_repair | Check and repair an XFS filesystem | | xfs_growfs | Grow (resize) an XFS filesystem | | xfs_info | Display metadata and usage information | | xfs_admin | Modify filesystem label or UUID |

Examples

Create an XFS filesystem:

bash

sudo mkfs.xfs /dev/sdb1

Grow an XFS filesystem (after resizing an LVM volume or partition):

bash

sudo xfs_growfs /mnt/data

Check filesystem information:

bash

sudo xfs_info /mnt/data

Real-life use case

An enterprise administrator increases the LVM logical volume for /var and uses xfs_growfs to expand the mounted XFS filesystem without unmounting it.

2. Ext4 Filesystem Tools

Ext4 (Fourth Extended Filesystem) is the default filesystem on many Linux distributions. It is stable, fast, and supports journaling, large volumes, delayed allocation, and backward compatibility with ext3/ext2.

Common tools

| Command | Purpose | | mkfs.ext4 | Create an Ext4 filesystem | | e2fsck | Check and repair Ext4 filesystems | | resize2fs | Resize the filesystem | | tune2fs | Modify filesystem settings (e.g., interval checks) | | dumpe2fs | Display filesystem metadata | | blkid | Show UUIDs and filesystem types |

Examples

Create an Ext4 filesystem:

bash

sudo mkfs.ext4 /dev/sdb1

Check and repair a filesystem:

bash

sudo e2fsck -f /dev/sdb1

Resize a filesystem:

bash

sudo resize2fs /dev/sdb1

Label the filesystem:

bash

sudo e2label /dev/sdb1 data_volume

Real-life use case

A Linux administrator schedules e2fsck to run at boot for a data partition after encountering read errors in system logs.

3. Btrfs Filesystem Tools

Btrfs (B-tree Filesystem) is a modern Linux filesystem that offers advanced features such as snapshots, subvolumes, checksumming, self-healing, and native RAID support.

Common tools

| Command | Purpose | | mkfs.btrfs | Create a Btrfs filesystem | | btrfs filesystem | Show usage, defragment, resize, etc. | | btrfs subvolume | Create and manage subvolumes/snapshots | | btrfs scrub | Verify and repair checksums | | btrfs balance | Rebalance data across disks | | btrfs check | Check filesystem consistency |

Examples

Create a Btrfs filesystem:

bash

sudo mkfs.btrfs /dev/sdb1

Create a subvolume:

bash

sudo btrfs subvolume create /mnt/data/@snap1

Start a scrub:

bash

sudo btrfs scrub start /mnt/data

Show filesystem usage:

bash

sudo btrfs filesystem df /mnt/data

Real-life use case

A DevOps engineer uses Btrfs subvolumes and snapshots to manage application data. Before updates, a snapshot is created for quick rollback in case of failure.

Summary Comparison

| Filesystem | Notable features | Key tools | Best for | | XFS | High performance, great with large files | xfs_growfs, xfs_repair | Enterprise storage, logs, large files | | Ext4 | Stable, fast, widely supported | e2fsck, resize2fs, tune2fs | General-purpose desktop/server use | | Btrfs | Snapshots, checksumming, subvolumes | btrfs, scrub, balance | Advanced setups, DevOps, container storage |

4. Monitoring Storage Space and Disk Usage

Understanding disk usage is critical for managing system health and avoiding downtime. Linux provides several tools to monitor overall disk capacity and individual file or directory usage. Two of the most widely used commands are df and du.

1. df – Display Free Disk Space

The df (disk free) command reports overall disk space usage on mounted filesystems. It provides information such as total space, used space, available space, and the mount point.

Syntax:

bash

df [options] [path]

Common Options:

  • -h – Human-readable format (e.g., KB, MB, GB)
  • -T – Show filesystem type
  • -x – Exclude specific filesystem types
  • --total – Show a grand total at the end

Examples:

Display disk space in human-readable format:

bash

df -h

Show filesystem types and usage:

bash

df -hT

Check space used by the /home mount:

bash

df -h /home

Sample output:

bash

Filesystem      Size  Used Avail Use% Mounted on /dev/sda1        50G   35G   12G  75% / tmpfs           1.9G     0  1.9G   0% /dev/shm

Real-life use case:

A sysadmin runs df -h daily on a monitoring script to ensure critical volumes like /var and /home don’t exceed safe usage thresholds.

2. du – Disk Usage of Files and Directories

The du (disk usage) command shows how much space files and directories take up. Unlike df, which works at the filesystem level, du is ideal for checking usage within a directory.

Syntax:

bash

du [options] [path]

Common Options:

  • -h – Human-readable output
  • -s – Show only the total size for each argument
  • -c – Display a grand total
  • --max-depth=N – Limit depth of subdirectory output

Examples:

Check the size of a specific directory:

bash

du -sh /var/log

Show size of directories one level deep:

bash

du -h --max-depth=1 /home

Display size of all files and include total:

bash

du -ch /etc

Sample output:

bash

120K    /var/log/apache2 80M     /var/log/journal 500M    /var/log

Real-life use case:

An administrator investigates low disk space and uses du -h --max-depth=1 / to find that /var/log is consuming most of the space due to oversized log files.

Summary Comparison

| Command | Purpose | Scope | Best for | | df | Shows filesystem space usage | Whole mount points | Monitoring available space system-wide | | du | Shows disk usage of directories | Specific directories | Finding space-hungry folders/files |

5. Creating and Modifying Volumes Using Logical Volume Manager (LVM)

Overview

Logical Volume Manager (LVM) is a device-mapping layer that allows more flexible management of disk storage than traditional partitioning schemes. LVM enables dynamic resizing of volumes, easy storage expansion, volume snapshots, and the aggregation of multiple physical devices into a unified storage pool.

LVM is particularly useful in environments where storage demands change over time (e.g., production servers, virtualized environments, and backup servers), as it provides more control over how storage is allocated and used.

1. Physical Volumes (PVs)

These are raw storage devices or partitions (e.g., /dev/sdb1, /dev/nvme0n1p2) that are initialized using LVM. After initialization, they can be added to volume groups.

bash

sudo pvcreate /dev/sdb1

pvs – View Physical Volumes

The pvs command displays physical volumes and their status within volume groups.

Example:

bash

pvs

Sample Output:

bash

PV         VG       Fmt  Attr PSize   PFree /dev/sdb1  vg_data  lvm2 a--  100.00g 20.00g

This output shows that /dev/sdb1 is a physical volume that belongs to volume group vg_data, has a total size of 100 GB, and still has 20 GB of unallocated space.

2. Volume Groups (VGs)

A volume group combines one or more physical volumes into a single storage pool from which logical volumes can be created.

bash

sudo vgcreate vg_data /dev/sdb1

vgs – View Volume Groups

The vgs command summarizes volume group properties, including the number of physical volumes (PVs), logical volumes (LVs), and available free space.

Example:

bash

vgs

Sample Output:

less

VG       #PV #LV #SN Attr   VSize   VFree vg_data    1   2   0 wz--n- 100.00g 20.00g

This tells us that vg_data contains one PV, two LVs, and no snapshots, with 20 GB of free space remaining.

3. Logical Volumes (LVs)

Logical volumes are the equivalent of partitions but are more flexible. They can be resized or snapshotted without rebooting or unmounting (depending on the filesystem).

bash

sudo lvcreate -L 20G -n lv_home vg_data

lvs – View Logical Volumes

The lvs command lists all logical volumes and their attributes, such as size, volume group membership, and device path.

Example:

bash

lvs

Sample Output:

lua

LV      VG       Attr       LSize   lv_home vg_data  -wi-ao---- 40.00g  lv_logs vg_data  -wi-ao---- 40.00g

This shows two logical volumes in the vg_data volume group, each 40 GB in size. The -wi-ao---- attribute string indicates the volume is writeable (w), has an inherited allocation policy (i), and is active (a).

Step 1: Create a physical volume

bash

sudo pvcreate /dev/sdc1

Step 2: Extend the existing volume group

bash

sudo vgextend vg_data /dev/sdc1

Step 3: Extend the logical volume

bash

sudo lvextend -L +50G /dev/vg_data/lv_home

Step 4: Resize the filesystem

  • If the filesystem is Ext4: bash sudo resize2fs /dev/vg_data/lv_home
  • If the filesystem is XFS: bash sudo xfs_growfs /home

Note: XFS filesystems must be mounted to resize, while Ext4 can be resized mounted or unmounted.

Step 5: Verify volume and space updates

bash

pvs vgs lvs df -h /home

4. vgcreate – Create a Volume Group

The vgcreate command is used to initialize a new volume group (VG) from one or more physical volumes. A VG acts as a container for logical volumes (LVs) and defines the pool of space from which they are created.

Syntax:

bash

sudo vgcreate <volume_group_name> <physical_volume> [...]

Example:

bash

sudo vgcreate vg_data /dev/sdb1

This command creates a volume group named vg_data using the physical volume /dev/sdb1.

Real-life use case:

A sysadmin attaches a new SSD to the system, creates a physical volume on it using pvcreate, then creates a new volume group vg_ssd to separate fast I/O workloads.

5. lvcreate – Create a Logical Volume

The lvcreate command is used to create a new logical volume (LV) within an existing volume group. Logical volumes can be used like partitions to store filesystems, mount directories, or serve as swap space.

Syntax:

bash

sudo lvcreate -L -n <lv_name> <volume_group>

Example – create a 50 GB volume:

bash

sudo lvcreate -L 50G -n lv_backup vg_data

This creates a logical volume named lv_backup inside the vg_data volume group, allocating 50 GB of space.

Other options:

  • -l instead of -L allows specifying size in extents (useful for full VG usage)
  • -s is used for snapshot volumes
  • --thin creates thin-provisioned volumes (when using thin pools)

Real-life use case:

An admin creates a 20 GB LV for /var to separate application logs and make it easier to expand or snapshot independently of the root filesystem.

6. lvchange – Change Logical Volume Attributes

The lvchange command is used to change properties of a logical volume, such as its activation status, read/write mode, availability, or monitoring settings.

Syntax:

bash

sudo lvchange [options] <volume_path>

Common options:

  • -a y – Activate the logical volume
  • -a n – Deactivate the logical volume
  • -r – Set volume to read-only
  • -w – Set volume to writeable
  • --monitor y|n – Enable or disable LVM monitoring

Example – activate a volume:

bash

sudo lvchange -a y /dev/vg_data/lv_backup

This activates the logical volume so it can be mounted and used.

Example – make a volume read-only:

bash

sudo lvchange -pr /dev/vg_data/lv_backup

This remounts the logical volume as read-only for security or forensic purposes.

Real-life use case:

A system administrator boots into recovery mode and needs to manually activate encrypted LVM volumes before mounting the root filesystem:

bash

sudo lvchange -a y /dev/mapper/vg_root-lv_root

7. pvcreate – Initialize a Physical Volume

The pvcreate command prepares a physical storage device or partition for use with LVM. This is the first step before adding the device to a volume group.

Syntax:

bash

sudo pvcreate /dev/sdX1

Example:

bash

sudo pvcreate /dev/sdc1

This initializes the /dev/sdc1 partition as an LVM physical volume.

Real-life use case:

After installing a new SSD, an administrator uses pvcreate to make the disk ready for use in an existing or new volume group for application data.

Notes:

  • You can use entire disks (e.g., /dev/sdb) or partitions (/dev/sdb1)
  • Data on the device will be overwritten—use with caution

8. vgextend – Add a Physical Volume to a Volume Group

The vgextend command adds a new physical volume (PV) to an existing volume group (VG), effectively increasing the total available storage space in that group.

Syntax:

bash

sudo vgextend <volume_group_name> <physical_volume>

Example:

bash

sudo vgextend vg_data /dev/sdc1

This adds /dev/sdc1 to the volume group vg_data.

Real-life use case:

An LVM volume group used for storing backups (vg_backup) runs low on space. A second disk is installed, initialized with pvcreate, and added using vgextend to grow the pool of storage for the group.

9. lvresize – Resize a Logical Volume

The lvresize command is used to increase or decrease the size of a logical volume (LV). You must also resize the filesystem (either before or after, depending on the type) to match the new volume size.

Syntax:

bash

sudo lvresize [options] <lv_path>

Common options:

  • -L + – Increase size by a specified amount
  • -L – Set a new size explicitly
  • -r – Resize the filesystem along with the logical volume (works with ext4 and XFS)

Example – increase size by 20 GB:

bash

sudo lvresize -L +20G /dev/vg_data/lv_home

Example – shrink volume to 40 GB (filesystem must be unmounted for ext4):

bash

sudo umount /home sudo e2fsck -f /dev/vg_data/lv_home sudo resize2fs /dev/vg_data/lv_home 40G sudo lvresize -L 40G /dev/vg_data/lv_home

Example – auto-resize LV and filesystem:

bash

sudo lvresize -r -L +10G /dev/vg_data/lv_home

-r automatically handles filesystem resizing using the appropriate tool (e.g., resize2fs for ext4 or xfs_growfs for XFS).

Real-life use case:

A developer's virtual machine runs out of space on /home. After extending the underlying volume group, the admin runs lvresize -r to grow the logical volume and its ext4 filesystem without downtime.

6. Inspecting RAID Implementations

RAID (Redundant Array of Independent Disks) is a method of combining multiple physical disks to improve performance, provide redundancy, or both. In Linux, mdadm is the most common tool used to manage and inspect software RAID arrays created using MD (multiple device) driver.

Two main tools are used to inspect and monitor RAID configurations:

  • mdadm – Userspace tool to create and manage software RAID
  • /proc/mdstat – Kernel-level status display for active MD RAID arrays

1. mdadm – Manage and Inspect Software RAID

mdadm (Multiple Device Admin) is a powerful utility for creating, assembling, and monitoring software RAID arrays in Linux. It's used for both setup and real-time inspection.

Inspecting RAID arrays with mdadm

1. Show detailed information about an active array:

bash

sudo mdadm --detail /dev/md0

Example output:

yaml

/dev/md0:         Version : 1.2   Creation Time : Mon Apr  1 10:32:11 2024      Raid Level : raid5      Array Size : 976630784 (931.51 GiB 1000.20 GB)   Used Dev Size : 488315392 (465.75 GiB 500.10 GB)    Raid Devices : 3   Total Devices : 3     State : clean

Devices :            /dev/sdb1            /dev/sdc1            /dev/sdd1

2. List all active arrays:

bash

sudo mdadm --detail --scan

Example output:

pgsql

ARRAY /dev/md0 level=raid5 num-devices=3 UUID=38e450d3:eaecf831:91dbde5f:53f2d7c2

This output is often used in /etc/mdadm/mdadm.conf for array auto-assembly during boot.

3. Examine RAID metadata on a specific device:

bash

sudo mdadm --examine /dev/sdb1

This reveals RAID superblock information on that device, including UUID, RAID level, and sync state.

2. /proc/mdstat – Kernel-Level RAID Status

The /proc/mdstat file provides real-time status of all active MD RAID arrays running in the kernel. It is read-only and updated continuously by the kernel.

View RAID array status:

bash

cat /proc/mdstat

Example output:

yaml

Personalities : [raid1] [raid5] md0 : active raid5 sdd1[3] sdc1[1] sdb1[0]       976630784 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

unused devices:

Interpretation:

  • md0 is an active RAID 5 array with 3 disks.
  • [3/3] means 3 out of 3 disks are online.
  • [UUU] indicates all disks are functioning properly (each "U" stands for a healthy disk).

If you see [U_U], it means one disk is missing or failed.

Real-Life Use Case: Verifying RAID Health on a Production Server

Scenario: An administrator needs to verify the status of a software RAID 1 mirror on a database server after noticing slower disk performance.

Steps:

  • Check kernel status: bash cat /proc/mdstat
  • View detailed info: bash sudo mdadm --detail /dev/md0
  • Check individual disk status: bash sudo mdadm --examine /dev/sdb1
  • Set up monitoring or alerting: Install and configure mdadm to send email alerts if a disk fails: bash CopyEdit sudo mdadm --monitor --scan [email protected] --daemonise

Summary Table

| Tool | Purpose | Common Use Case | | mdadm --detail | Inspect full RAID array configuration | View level, size, state, and devices | | mdadm --examine | View metadata on RAID member disks | Diagnose or recover broken arrays | | /proc/mdstat | Monitor RAID status (live, read-only) | Check sync progress or array health |

7. Storage Area Network (SAN) and Network-Attached Storage (NAS)

In enterprise environments, large-scale storage is often accessed over a network, either via block-level protocols (SAN) or file-level protocols (NAS). Linux supports both through tools and services that manage connections, mount points, redundancy, and failover.

SAN vs NAS – Key Differences

| Feature | SAN | NAS | | Protocol | Block-level (iSCSI, FC) | File-level (NFS, SMB/CIFS) | | Appears as | A raw block device (like /dev/sdX) | A mounted directory (e.g., /mnt/nas) | | Performance | High-performance, low latency | Depends on network and protocol | | Use Case | Databases, VM storage, critical apps | File sharing, backups, user data |

SAN in Linux – Multipath I/O with multipathd

SAN environments often provide multiple paths to the same storage device for redundancy and load balancing. Linux uses Device Mapper Multipath to manage these paths.

multipathd – Multipath Daemon

multipathd manages multipath I/O routing. It detects multiple paths to storage devices and merges them into a single device for the system to use.

Commands

Enable multipath services:

bash

sudo systemctl enable --now multipathd

Check multipath status:

bash

sudo multipath -ll

Sample output:

lua

3600508b400105e210000900000490000 dm-2 IBM,2107900 features='1 queue_if_no_path' hwhandler='0' wp=rw |-+- policy='round-robin 0' prio=1 status=active | |- 3:0:0:1 sdb 8:16 active ready running | |- 4:0:0:1 sdc 8:32 active ready running

This shows two active paths (sdb, sdc) to a 200 GB SAN LUN managed as a single device (/dev/mapper/mpatha).

Real-life use case:

A high-availability database server is connected to a SAN via redundant Fibre Channel HBAs. If one path fails, multipathd reroutes I/O to the remaining path, maintaining uptime.

NAS in Linux – Network File Systems

NAS allows file-level access over the network using protocols like NFS and SMB/CIFS. These systems export directories that clients can mount and access as though they were local folders.

Network File System (NFS)

NFS is a protocol developed for Unix-like systems that allows files to be shared over a TCP/IP network. It is widely used in Linux environments.

Mounting an NFS share:

bash

sudo mount -t nfs 192.168.1.100:/exports/backups /mnt/nfs

Making it persistent in /etc/fstab:

ruby

CopyEdit

192.168.1.100:/exports/backups /mnt/nfs nfs defaults 0 0

Installing NFS client:

bash

CopyEdit

sudo apt install nfs-common # Debian/Ubuntu

sudo yum install nfs-utils # RHEL/CentOS

Real-life use case:

A web server farm mounts the same shared /var/www/html from an NFS server to ensure consistent content across all nodes.

Server Message Block (SMB)/Common Internet File System (CIFS)

SMB/CIFS is a file-sharing protocol used primarily in Windows environments but also supported by Linux via the cifs kernel module.

Mounting an SMB share:

bash

sudo mount -t cifs //192.168.1.200/shared /mnt/smb -o username=admin,password=pass123

Persistent mount in /etc/fstab:

bash

//192.168.1.200/shared /mnt/smb cifs username=admin,password=pass123,iocharset=utf8 0 0

Credentials can be stored securely in a file:

makefile

/etc/smb-credentials: username=admin password=pass123

Then use in fstab:

bash

/mnt/smb cifs credentials=/etc/smb-credentials 0 0

Real-life use case:

Linux desktops in a mixed OS office environment mount shared drives from a Windows file server using SMB/CIFS for cross-platform file access.

Summary Table

| Component | Protocol Type | Command or Tool | Use Case | | SAN | Block-level | multipathd | Redundant and high-performance storage | | NFS (NAS) | File-level | mount -t nfs | Linux-to-Linux file sharing | | SMB/CIFS (NAS) | File-level | mount -t cifs | Linux clients accessing Windows shares |

8. Storage Hardware in Linux

Understanding storage hardware and how it’s connected and identified by the system is a critical task for Linux system administrators. Whether managing local disks, SAN-attached LUNs, or hot-swappable devices, Linux provides several built-in and external tools to inspect storage devices and their metadata.

1. lsscsi – List SCSI Devices

The lsscsi command lists SCSI devices (including SATA, SAS, Fibre Channel, and some NVMe devices if bridged), showing how they are connected and their SCSI IDs.

Syntax:

bash

lsscsi [options]

Example output:

bash

[0:0:0:0]    disk    ATA      Samsung SSD 850  2B6Q  /dev/sda [3:0:0:0]    disk    HP       LOGICAL VOLUME   4.62  /dev/sdb

Key columns:

  • [H:C:T:L] → Host, Channel, Target, LUN (SCSI ID)
  • Device type (e.g., disk, cdrom)
  • Vendor and model
  • Device path (e.g., /dev/sda)

Use case:

  • Identify which disk is physically connected to which controller.
  • Verify LUN visibility from SAN storage.

If not installed, install with:

bash

sudo apt install lsscsi       # Debian/Ubuntu sudo yum install lsscsi       # RHEL/CentOS

2. lsblk – List Block Devices

The lsblk command provides a tree view of block devices, including partitions, mount points, and sizes.

Syntax:

bash

lsblk [options]

Common options:

  • -f – Show filesystem type, label, and UUID
  • -o – Customize output columns (e.g., NAME,SIZE,TYPE,MOUNTPOINT)

Example output:

pgsql

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT sda      8:0    0  100G  0 disk ├─sda1   8:1    0   96G  0 part / ├─sda2   8:2    0    1G  0 part [SWAP] sdb      8:16   0  500G  0 disk /mnt/storage

Use case:

  • Visualize how disks and partitions are laid out
  • Check which volumes are mounted and where
  • Identify removable drives and RAID/LVM mappings

3. blkid – Identify Block Devices and UUIDs

The blkid command provides detailed metadata for block devices, including UUIDs, filesystem types, and labels. It’s commonly used in automation and scripting to reference devices reliably in /etc/fstab.

Syntax:

bash

sudo blkid

Example output:

pgsql

/dev/sda1: UUID="d1f7-8cb2" TYPE="ext4" PARTUUID="3e0c93d8-01" /dev/sdb1: UUID="4baf-2341" TYPE="xfs"

Use case:

  • Retrieve the UUID to use in /etc/fstab: ini UUID=d1f7-8cb2 /mnt/data ext4 defaults 0 2
  • Match devices to specific partitions or volumes

4. fcstat – Fibre Channel Port and Link Statistics

fcstat is used to display Fibre Channel host bus adapter (HBA) statistics, such as link status, I/O activity, and errors. This tool is specific to IBM AIX and some Fibre Channel drivers on Linux, such as QLogic or Emulex HBAs.

On Linux, Fibre Channel status is often checked using:

  • /sys/class/fc_host/
  • Vendor-specific tools like systool (for QLogic)
  • Or packages like sg3_utils or lspci

Typical use on supported systems:

bash

fcstat fcs0

Sample output:

yaml

FIBRE CHANNEL STATISTICS REPORT: fcs0 Port Name: 2100001b32170d56 Node Name: 2000001b32170d56 Port Speed: 8Gbps Link Status: Up LIP Count: 0 Loss of Sync Count: 0

Use case:

  • Monitor Fibre Channel HBA health and connectivity
  • Diagnose dropped connections or degraded link speed

Summary Table

| Command | Purpose | Use Case | | lsscsi | Show SCSI device mapping | Identify disk vendor/model and connection | | lsblk | List block devices and hierarchy | Visualize disk layout and mount points | | blkid | Show filesystem metadata and UUIDs | Use in /etc/fstab for persistent mounts | | fcstat | Fibre Channel port diagnostics (if supported) | Diagnose SAN link or HBA issues |