Disks and data

Disks and data

Storage and Filesystems

Understand disks, partitions, block devices, mount points, ext4, btrfs, xfs, swap, filesystem checks, and disk usage analysis.

Audience
Users managing disks or installations
Reading time
19 min
Modern partition table
GPT
Common default
ext4
Memory support
swap

The storage stack

Linux storage is layered. A physical disk exposes block devices. A partition table divides a disk. Partitions or logical volumes contain filesystems or swap. Filesystems are mounted into the directory tree.

Commands such as lsblk, blkid, df, du, mount, and find answer different questions at different layers.

The storage stack diagram
Diskhardware
Partition tablemap
Filesystemformat
Mount pointdirectory

Disks, partitions, and block storage

A block device is storage addressed in blocks rather than named files. Disks often appear as /dev/sda, /dev/nvme0n1, or /dev/vda. Partitions appear as names under those disks, such as /dev/sda1 or /dev/nvme0n1p2.

Do not rely on device names staying the same across hardware changes. UUIDs and labels are safer for persistent mounts.

ext4, btrfs, and xfs

A filesystem defines how files and directories are stored inside a partition or volume. The best choice depends on your distribution defaults, backup approach, snapshot needs, and recovery comfort.

ext4, btrfs, and xfs
FilesystemStrengthTypical use
ext4Mature, simple, reliable defaultGeneral-purpose Linux systems
btrfsSnapshots, checksums, subvolumesDesktops with rollback, advanced storage features
xfsStrong performance for large filesystemsServers, large storage volumes

Swap

Swap is disk-backed memory support. It can prevent immediate out-of-memory failures and may be required for hibernation. It is slower than RAM, so heavy swapping usually means the system needs less workload or more memory.

Modern distributions may use swap partitions, swap files, zram, or a combination. The concept is the same: provide memory pressure relief outside normal RAM.

Filesystem checks and disk usage analysis

Use df when the question is which filesystem is full. Use du when the question is which directory consumes space. Use lsblk and blkid when the question is what disks, partitions, filesystems, and UUIDs exist.

Filesystem capacity
df -h
Directory usage
du -h -d 1 /var 2>/dev/null | sort -h
Block device map
lsblk -f

SSD vs HDD, MBR vs GPT

SSDs are faster and have no spinning platters. HDDs are slower but still common for inexpensive large storage. Linux works with both, but SSDs benefit from proper discard/TRIM handling, usually configured by the distribution.

MBR is the older partition table format with limitations. GPT is the modern default, especially for UEFI systems and large disks.

Practical storage management tips

  • Keep backups before partitioning or filesystem repair.
  • Use lsblk -f before mounting or formatting so you identify the correct device.
  • Prefer UUIDs in /etc/fstab for persistent mounts.
  • Do not run filesystem repair tools on mounted writable filesystems unless documentation says it is safe.
  • Investigate disk-full problems before deleting broadly; logs, caches, containers, and snapshots are common causes.