Files
Documentation/Doc/Linux/Storage.md
T
2026-03-05 17:47:01 +01:00

172 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Linux Storage
Overview of storage concepts on Linux systems. It Focus on how disks, partitions, file systems, and mount points fit together.
General introduction to Linux and its filesystem layout:
- [Linux / Basics](./Basics.md)
---
## 1. Disks, Partitions, and Devices
On Linux, disks and partitions are exposed as device files under `/dev`.
Typical examples:
- `/dev/sda`, `/dev/sdb` whole disks (SATA/SCSI).
- `/dev/nvme0n1` NVMe disk.
- `/dev/sda1`, `/dev/sda2` partitions on `/dev/sda`.
- `/dev/nvme0n1p1` partition on an NVMe disk.
Key ideas:
- A **disk** can contain one or more **partitions**.
- A **file system** is created on a partition (or on other block devices such as LVM volumes).
---
## 2. File Systems
Common Linux file systems include:
- **ext4** widely used default file system on many distributions.
- **xfs** often used on servers, good for large files and parallel workloads.
- **btrfs**, **zfs** advanced file systems with snapshots and additional features.
Responsibilities of a file system:
- Organising data into files and directories.
- Tracking metadata (permissions, timestamps, ownership).
- Handling allocation on the underlying block device.
The choice of file system depends on requirements such as performance, robustness, and feature set (for example snapshot support).
---
## 3. Mount Points and the Unified Tree
Linux presents storage through a single unified directory tree.
To make a file system available, it is **mounted** at a directory path (the mount point).
Examples:
- A root file system on `/`.
- Additional storage mounted under `/srv`, `/mnt`, or `/data`.
- Removable media mounted under `/media` or `/run/media`.
Important aspects:
- The same directory path can hide existing contents when a new file system is mounted on top of it.
- Consistent mount points simplify backups and documentation.
---
## 4. /etc/fstab and Persistent Mounts
The file `/etc/fstab` defines which file systems are mounted at boot.
Each entry typically specifies:
- The device (for example a UUID or `/dev/sda1`).
- The mount point (for example `/srv/data`).
- The file system type (for example `ext4`).
- Mount options.
Conceptual points:
- Using UUIDs or labels makes mounts more stable than relying on `/dev/sdX` names.
- Mount options can influence performance and safety (for example `noatime`, `defaults`, `ro`).
- Misconfigured entries can prevent the system from booting cleanly, so changes should be tested carefully.
Projectspecific mount layouts (for example for application data) can be documented alongside the systems that use them.
---
## 5. LVM and RAID (Overview)
In addition to simple diskpartitionfilesystem setups, Linux supports more advanced storage layers.
### 5.1 LVM (Logical Volume Manager)
LVM introduces an extra abstraction layer:
- Physical volumes (PVs) are typically partitions or whole disks.
- Volume groups (VGs) combine one or more PVs.
- Logical volumes (LVs) are created inside VGs and used like regular block devices.
Advantages:
- Flexible resizing of logical volumes.
- Ability to span volumes across multiple physical disks.
### 5.2 RAID (mdadm and hardware RAID)
RAID (Redundant Array of Independent Disks) is used for redundancy, performance, or both.
Common levels:
- RAID 1 mirroring for redundancy.
- RAID 5/6 striping with parity.
- RAID 10 combination of striping and mirroring.
Implementation options:
- Software RAID with `md` devices (managed by tools such as `mdadm`).
- Hardware RAID controllers that present a single virtual disk.
LVM and RAID are often combined for flexibility and resilience.
---
## 6. Swap Space
Swap provides additional virtual memory by using disk space when physical RAM is exhausted.
Swap can be configured as:
- A dedicated swap partition.
- A swap file on an existing file system.
Considerations:
- Swap is much slower than RAM, but can prevent outofmemory conditions.
- On some systems, hibernation relies on swap configuration.
---
## 7. Monitoring Space Usage (Conceptual)
Administrators need to keep track of available disk space and inode usage.
Key concepts:
- Total vs used vs available space for each mounted file system.
- Inode counts (maximum number of files/directories a file system can track).
- Distinguishing usage on the root file system from usage on separate data file systems.
Concrete commands for checking disk and inode usage can be listed in:
- [Linux / Cheat Sheet](./CheatSheet.md)
---
## 8. BackupFriendly Layouts
Storage layout has a strong impact on backup and restore strategies.
General considerations:
- Separating system files from application and user data simplifies targeted backups.
- Grouping related data under welldefined mount points (for example `/srv`) makes it easier to snapshot or back up.
- Avoiding unnecessary writes on system partitions can reduce wear on SSDs.
Backup strategies themselves are usually documented alongside the systems or applications that depend on them.
---
## 9. Relation to Other Documents
- Highlevel Linux concepts: [Linux / Basics](./Basics.md)
- Administration topics (permissions, services, backups): [Linux / Administration](./Administration.md)