Disks and filesystems

Map the storage stack

Separate physical or virtual devices, partitions, volume management, filesystems, and mount points.

Server storage is a stack. A filesystem is not the same thing as the disk or logical volume underneath it.

When a disk fills up or fails, you fix the problem at one specific layer. If you cannot name the layers, you end up guessing.

The layers

From bottom to top:

  • A block device: a physical disk, cloud volume, or virtual disk. Cloud volumes and virtual disks still appear as block devices inside Linux, with names like /dev/sda or /dev/nvme0n1.
  • An optional partition, a slice of that device.
  • An optional volume management layer such as LVM, which pools devices and hands out flexible volumes.
  • A filesystem such as ext4 or XFS, which turns raw blocks into files and directories.
  • A mount point, the directory where that filesystem becomes visible.

Capacity is owned near the bottom. Files are owned at the top. You grow a disk at the block layer, but you free space at the filesystem layer.

See the whole stack

lsblk -f shows devices, partitions, filesystem types, labels, UUIDs, and mount points in one view:

lsblk -f
NAME           FSTYPE      LABEL UUID                                 MOUNTPOINTS
sda
├─sda1         vfat              70D2-1F02                            /boot/efi
├─sda2         ext4              1c24164b-92e0-43d9-a5cb-9b1d2f3a8a11 /
└─sda3         LVM2_member       pXlZ2f-Qm3t-0dKe-7hgB-Vc2a-N9uY-4rTq
  └─vg0-data   ext4              9a7f43c2-6c1d-4c2e-8f3a-2b64d0e51c77 /srv/data
sdb            ext4              4e0c2ab8-11f9-4b62-9d34-8a2f6c0d91be /mnt/backups

The indentation is the stack itself. sda3 is a partition, it belongs to LVM, and the logical volume vg0-data carries the ext4 filesystem mounted at /srv/data.

Trace one path

To answer “which device holds this directory?”, ask findmnt:

findmnt /srv/data
TARGET    SOURCE               FSTYPE OPTIONS
/srv/data /dev/mapper/vg0-data ext4   rw,relatime

Here is a classic mistake this catches. A big data volume exists, but it was never mounted, so /srv/data is just an empty directory on the root filesystem. The application writes there happily until the small root disk fills. findmnt would have shown the source as /dev/sda2, not the data volume.

Try this on your own server: pick one path under /srv, run findmnt on it, and draw the stack down to the block device. Mark which layer owns capacity and which layer owns files.

Lesson completed