Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Local storage on Linux: the complete path

  • 20 min

By updated

Improve this page

Adding and running a disk on Linux always follows the same cycle: identify the hardware, partition it, format it, mount it, then manage it over time. This page is the entry point of the storage section: it places each step and points to the dedicated guide. For beginner to intermediate administrators, on Ubuntu, Debian or RHEL. By the end, you will know which guide to open for your need, from the first lsblk to performance tuning.

The life cycle of storage

From the blank disk to the monitored volume, six steps follow one another. Each one has its guide; you can enter the path at the step that concerns you.

  1. Understand the Linux storage model (disks, partitions, file systems, mounting).
  2. Identify the disk to prepare.
  3. Partition then choose and create the file system.
  4. Mount the partition and make it persistent at boot.
  5. Manage flexibility and capacity with LVM and space tracking.
  6. Monitor health and performance.

Understand and identify

Before any manipulation, set the mental model and spot the right disk. Picking the wrong device (/dev/sda instead of /dev/sdb) destroys data: these two guides avoid the mistake.

The storage overview sets the disks, partitions, file systems and mounting model. Identify disks then teaches you to spot the right device with lsblk, blkid and the UUID, before any destructive command.

Partition and format

Once the disk is spotted, split it into partitions (GPT by default) then format it with the suitable file system. The deciding criterion: ext4 (Debian/Ubuntu default) resizes both ways, while XFS (RHEL default) performs better but is not shrunk in practice, shrinking only existing in experimental mode. Hence a dedicated decision guide.

The guide to manage partitions creates a GPT or MBR table with parted and takes care of alignment. Choose a file system decides between ext4, XFS and Btrfs by use. Two guides then detail each format: ext4, resizable with resize2fs, and XFS, which performs better but is not shrunk.

Mount and make persistent

A formatted partition is only usable once mounted in the tree. For it to come back after a reboot, it must appear in /etc/fstab, preferably by UUID rather than by device name (which can change). Beware: a faulty line blocks the boot; the nofail option protects non-essential disks.

Mount and make persistent covers mount, /etc/fstab by UUID and the nofail option. For on-demand mounts, autofs mounts an NFS share or a home directory on first access, then unmounts it after an idle timeout.

Manage over time

In production, a disk evolves: a volume fills up, a partition must grow. LVM (Logical Volume Manager) brings this flexibility by decoupling logical volumes from physical disks; lvextend -r grows volume and file system online, in one command. Tracking capacity (including inodes, which can run out before space) avoids the first cause of incidents.

The LVM guide builds the stack and grows a volume online with lvextend -r. Manage swap compares a file, a partition and zram, and tunes swappiness. Disk capacity and quotas teaches you to read df and du, watch the inodes and find a deleted file still open that keeps taking up the disk.

Go further with LVM

Once LVM is in place, three operations cover most of daily work: freeze a volume before a risky operation, provision on demand without tying up disk, and move data from one disk to another with no downtime.

LVM snapshots give a consistent backup online and a rollback with lvconvert --merge. Thin provisioning creates a thin pool, allows overcommit and automatic extension. pvmove migrates or removes a disk without stopping the service.

Protect the data

Two different threats, two different answers. RAID protects against the failure of a disk; LUKS encryption protects against the theft of a disk. Neither replaces a backup.

Software RAID with mdadm builds a redundant array, with a spare disk and online replacement. Encrypt a disk with LUKS covers LUKS2, header backup, crypttab and network unlocking with NBDE.

Reach network storage

A server does not store everything locally. NFS and SMB share files between several machines; iSCSI presents a remote block disk to a single server, which formats it like a local disk.

Mount an NFS share goes from exports to an NFSv4.2 mount, with nofail and Kerberos. SMB/CIFS shares cover smbclient, the cifs mount and Samba hardening. iSCSI builds the whole block chain: a target with targetcli, the open-iscsi initiator and CHAP authentication.

Monitor health and performance

A disk that slows down or ages rarely warns you. S.M.A.R.T. monitoring anticipates failures, and measuring throughput, IOPS and latency identifies bottlenecks before they affect applications.

Analyse disk performance measures throughput, IOPS and latency with fio and iostat, and reads a disk's S.M.A.R.T. state before it gives up.

Complementary topics

Three topics extend this foundation and close the module, according to your needs:

  • Disk quotas: finely limit space per user or group, on ext4 and XFS.
  • Btrfs: modern file system with snapshots and subvolumes (reliable RAID 1/10, RAID 5/6 discouraged in production).
  • Identify and observe devices: lspci, lsusb, lshw, udev and dmesg to know what the machine has inside.

Key points

  • Linux storage follows a cycle: identify, partition, format, mount, manage, monitor.
  • Always identify the right disk before acting: a device mistake destroys data.
  • File system choice: ext4 shrinks, XFS (RHEL default) not in practice, Btrfs for snapshots.
  • Mount by UUID in /etc/fstab; nofail on non-essential disks avoids a blocked boot.
  • LVM grows a volume online (lvextend -r), freezes it (snapshot) and migrates it (pvmove); monitor space and inodes (df -i).
  • RAID against a disk failure, LUKS against its theft; NFS, SMB and iSCSI for network storage.
  • S.M.A.R.T. monitoring and throughput/IOPS/latency measurement prevent incidents.
  • This foundation covers the storage domain of the LFCS and RHCSA certifications.

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn