The block stack from the application down to the device: partitions and stable names, XFS and ext4, LVM with snapshots and thin pools, mdadm RAID, I/O measurement and network storage.
The application calls write(). It returns as soon as the kernel has the data, not when the data is on disk.
VFS resolves the path to an inode, checks permissions and hands the call to the right filesystem.
The data lands in the page cache as dirty pages. Writeback threads flush them later, or now if the program calls fsync().
The filesystem allocates blocks and journals the metadata change. ENOSPC can surface here, on writeback, long after write() returned.
Device mapper and md translate the logical block to one or more real devices: LVM extents, an encrypted sector, mirrored copies.
The block layer merges and queues requests, one hardware queue per CPU on NVMe. Latency and queue depth are measured here.
The driver submits the command to the controller: NVMe, virtio in a VM, or an EBS volume on a Nitro card.
The device completes the write. Only after fsync() returns successfully is the data guaranteed to survive a power loss.
The Linux storage stack
Every storage problem lives at a specific layer, and every tool reads a specific layer. Knowing which is which turns "the disk is slow" into a question you can answer.
VFS gives every filesystem the same interface: open, read, write, fsync. Path lookup, permissions and the dentry and inode caches live here.
Page cache holds file data in RAM. A normal write() returns once the data is in the cache. The kernel writes it back later, so a full disk can show up on close() or fsync() instead of write(). O_DIRECT bypasses the cache, and databases use it.
Filesystem (XFS, ext4, Btrfs) maps files to blocks and keeps a journal so a crash does not corrupt metadata.
Device mapper stacks virtual block devices: LVM, LUKS (dm-crypt), multipath, thin provisioning. Each one shows up as /dev/dm-N, with friendly names in /dev/mapper/.
md is the software RAID driver behind /dev/mdN.
Block layer (blk-mq) turns filesystem I/O into requests and queues them, one hardware queue per CPU on NVMe. The I/O scheduler sits here.
Drivers speak NVMe, SCSI/SAS/SATA, or virtio-blk and virtio-scsi in a VM. In EC2, EBS volumes are NVMe devices on Nitro instances.
Read the stack of a real machine
bash
lsblk -o NAME,TYPE,SIZE,FSTYPE,MOUNTPOINTS # the tree, from disk to mount point
dmsetup ls --tree # device-mapper layering
cat /proc/mdstat # software RAID
findmnt -T /var/lib/pgsql # which filesystem backs a path
lsblk answers most questions at once. A typical server tree reads like this: disk, partition, LUKS, LVM physical volume, logical volume, XFS, mount point. Change one layer, such as growing a disk, and every layer above it may need a matching step: growpart, pvresize, lvextend, xfs_growfs.
Which tool reads which layer
Question
Layer
Tool
Who is writing?
Process
pidstat -d 1, iotop
Is the cache absorbing it?
Page cache
free -h, grep -i dirty /proc/meminfo
Is the filesystem full?
Filesystem
df -hT, df -i
Is the device saturated?
Block layer
iostat -xz 1
Is the hardware failing?
Device
smartctl -a, nvme smart-log, dmesg
Disks, names and partitions
Names that change and names that do not
/dev/sda, /dev/nvme1n1 and /dev/vdb are assigned in the order devices are discovered, and that order is not guaranteed between boots. On Nitro instances, an EBS volume you attached as /dev/sdf shows up as some /dev/nvmeXn1. Reference disks by a stable name:
Path
Based on
Survives
/dev/disk/by-uuid/
Filesystem UUID
Reboots and device moves. A reformat changes it
/dev/disk/by-partuuid/
GPT partition GUID
A reformat of the filesystem
/dev/disk/by-id/
Model and serial number
Reboots. On EC2 the serial is the EBS volume ID
/dev/disk/by-path/
Bus position
Only as long as the cabling stays the same
bash
ls -l /dev/disk/by-id/ | grep -i ebs # EC2: nvme-Amazon_Elastic_Block_Store_vol...
udevadm info --query=property /dev/nvme1n1 | grep -E 'ID_SERIAL|ID_MODEL'
MBR or GPT
MBR stores four primary partitions in the first sector and cannot address more than 2 TiB with 512-byte sectors. GPT stores 128 entries by default. It keeps a backup header at the end of the disk and a protective MBR so old tools do not overwrite it. Use GPT for anything new. UEFI requires it for the boot disk.
bash
parted -s /dev/sdb mklabel gpt
parted -s /dev/sdb mkpart data xfs 1MiB 100%
parted -s /dev/sdb align-check optimal 1
partprobe /dev/sdb && udevadm settle # make the kernel re-read the table
Start partitions at 1 MiB. It aligns with every SSD erase block and RAID stripe in common use. Interactive alternatives are gdisk for GPT and fdisk, which handles both. For scripts, sfdisk --dump saves a table and sfdisk restores it.
Growing a disk that is already in use
Cloud volumes and virtual disks grow without downtime, but each layer above them must be told:
bash
lsblk /dev/nvme0n1 # disk shows the new size, partition still the old one
growpart /dev/nvme0n1 1 # grow partition 1 to the end of the disk (cloud-utils-growpart)
xfs_growfs / # XFS: grow by mount point, online
resize2fs /dev/nvme0n1p1 # ext4: grow by device, online
If the partition is an LVM physical volume, run pvresize /dev/nvme0n1p2 and then lvextend -r. Skip any layer and the size stays where it was, with no error.
Filesystems and mounts
XFS and ext4 side by side
XFS
ext4
Default on
RHEL family
Debian, Ubuntu
Grow
Online, by mount point: xfs_growfs /mnt
Online or offline: resize2fs /dev/X
Shrink
Not possible: back up and recreate
Offline only: e2fsck -f, then resize2fs /dev/X 20G
Inodes
Allocated dynamically
Fixed at mkfs, and can run out
Repair
xfs_repair on an unmounted device
e2fsck -f on an unmounted device
Reserved space
None
5% for root by default, tune2fs -m 1 to lower it
Inspect
xfs_info /mnt
tune2fs -l /dev/X, dumpe2fs -h
Btrfs adds checksums, snapshots and subvolumes. Fedora and openSUSE use it by default. RHEL does not ship it, so check the platform before you plan on it.
Never run a repair on a mounted filesystem. On XFS, if xfs_repair refuses because the log is dirty, mount and unmount once to replay it. Use -L to zero the log only as the last resort: it discards the metadata changes still in the log.
For XFS the last field is 0: XFS checks itself at mount time. For ext4, use 1 for / and 2 for other filesystems.
Options worth knowing: noatime (skips access-time writes), nodev,nosuid,noexec (hardening for /tmp and data paths), nofail (a missing device does not stop the boot), _netdev (wait for the network), x-systemd.automount (mount on first access), x-systemd.device-timeout=10s.
bash
findmnt --verify --verbose # check the whole file before you reboot
systemctl daemon-reload # regenerate mount units after editing
mount -a # mount everything not yet mounted
findmnt -o TARGET,SOURCE,FSTYPE,OPTIONS /var/lib/pgsql
A directory is not a mount
When a volume fails to mount, its mount point is still an ordinary directory on the parent filesystem. Applications keep writing there, the root filesystem fills up, and the data seems to vanish once the volume comes back and hides those files. findmnt -T <path> tells you which filesystem really holds a path.
LVM: physical volumes, groups and logical volumes
LVM puts a layer of indirection between filesystems and disks. Physical volumes (PVs) are split into fixed-size extents, 4 MiB by default. A volume group (VG) pools the extents of its PVs. Logical volumes (LVs) are lists of extents, mapped through device mapper, so they can grow, move between disks and take snapshots without the filesystem noticing.
Extents moving through LVM
Volume group vg_app
/dev/sdbNot a PV yet
/dev/sdcNot a PV yet
/dev/sddNot a PV yet
lv_data
lv_logs
Free extent
pvcreate /dev/sdb /dev/sdc Each disk gets an LVM label and is split into physical extents, 4 MiB each by default.
vgcreate vg_app /dev/sdb /dev/sdc The volume group pools the extents of both disks. Its free space is the sum.
lvcreate -n lv_data -l 8 vg_app lv_data takes 8 extents. They happen to be contiguous on sdb, but they do not have to be.
lvcreate -n lv_logs -l 4 vg_app lv_logs spans both disks: two extents on sdb, two on sdc. The filesystem never sees the seam.
lvextend -r -l +6 vg_app/lv_data lv_data grows online into free extents on sdc. -r grows XFS or ext4 in the same command.
vgextend vg_app /dev/sdd The VG ran low, so a third disk joins it. Nothing is unmounted.
lvextend -r -l +4 vg_app/lv_data lv_data now lives on three disks. lvs -o +devices shows the segments. Losing any of those disks loses the LV, unless it is a RAID LV.
bash
pvcreate /dev/sdb /dev/sdc
vgcreate vg_app /dev/sdb /dev/sdc
lvcreate -n lv_data -L 40G vg_app
mkfs.xfs /dev/vg_app/lv_data
pvs; vgs; lvs -a -o +devices,seg_pe_ranges # where each LV physically lives
Growing online
bash
lvextend -r -L +20G vg_app/lv_data # -r also grows the filesystem
lvextend -r -l +100%FREE vg_app/lv_data # use every free extent in the VG
vgextend vg_app /dev/sdd # add a disk when the VG is out of extents
-r calls fsadm, which runs xfs_growfs or resize2fs. Without it, the LV grows and df still shows the old size. Shrinking only works for ext4, unmounted, with lvreduce -r. XFS cannot shrink.
Moving data off a disk with no downtime
bash
pvmove /dev/sdb # migrate every extent to other PVs in the VG, online
vgreduce vg_app /dev/sdb
pvremove /dev/sdb
Snapshots and thin provisioning
A classic snapshot (lvcreate -s -L 5G -n snap vg_app/lv_data) is copy-on-write: the first write to each origin block copies the old block into the snapshot area. If that area fills up, the snapshot becomes invalid. Roll back with lvconvert --merge vg_app/snap. The merge waits for the next activation if the origin is open, so unmount it first.
A thin pool allocates blocks only when they are written, so LVs can promise more space than exists. That is useful and dangerous. Watch data_percent and metadata_percent, and set thin_pool_autoextend_threshold in /etc/lvm/lvm.conf. A pool at 100% makes every thin volume in it fail writes.
To mount an XFS snapshot next to its origin, add -o nouuid. Both carry the same filesystem UUID.
Two RHEL 9 details that catch people out
The devices file. LVM uses only the devices listed in /etc/lvm/devices/system.devices. A disk moved from another host, or a cloned volume, stays invisible to pvs until you run lvmdevices --adddev /dev/sdX or vgimportdevices <vg>.
Metadata backups. Every change writes a copy to /etc/lvm/backup/<vg> and keeps history in /etc/lvm/archive/. vgcfgrestore --list vg_app shows the versions you can return to after a mistaken lvremove, as long as nothing has overwritten the extents.
RAID with mdadm
RAID protects against a disk failing. It does not protect against deletion, corruption, ransomware or a bad rm -rf, because every one of those is copied to all members immediately. RAID is not a backup.
RAID levels: fail a disk and see what survives
D1D5D9P
D2D6PD10
D3PD7D11
PD4D8D12
Optimal: every block has all its copies or parity.
Usable capacity: 3 of 4 disksSurvives any 1 failure
Select a disk to fail it, and select it again to replace it and watch the rebuild.
Data
Parity
Level
Minimum disks
Usable capacity
Survives
Write cost
RAID 0
2
n × disk
No failures
None, fastest
RAID 1
2
1 × disk
n − 1 failures
Every write goes to every disk
RAID 5
3
(n − 1) × disk
1 failure
Read-modify-write for parity
RAID 6
4
(n − 2) × disk
2 failures
Two parity blocks per stripe
RAID 10
4
n / 2 × disk
1 per mirror pair
Mirror writes, no parity
A RAID 5 rebuild reads every surviving disk end to end. With large disks, a second failure or an unreadable sector during that window loses the array. That risk is why RAID 6 or RAID 10 is the usual choice for big drives.
Persisting the configuration and rebuilding the initramfs matters most when the array holds root. Without that step it can come up as /dev/md127 with another name, or not at all.
Replace a failed disk
bash
mdadm --manage /dev/md0 --fail /dev/sdb1 # only if the kernel has not marked it yet
mdadm --manage /dev/md0 --remove /dev/sdb1
# swap the disk, copy the partition table from the healthy member:
sgdisk -R /dev/sdb /dev/sdc && sgdisk -G /dev/sdb
mdadm --manage /dev/md0 --add /dev/sdb1
watch -n2 cat /proc/mdstat # [U_] becomes [UU] when the rebuild ends
In /proc/mdstat, [UU] means healthy and _ marks a missing member. (F) after a device name means it has failed. Rebuild speed is bounded by /proc/sys/dev/raid/speed_limit_min and speed_limit_max. Raise the minimum to finish sooner, at the cost of production I/O.
Hardware RAID, md or LVM RAID
Hardware RAID: the controller hides the disks. You manage it with the vendor CLI (storcli, ssacli), and a cache battery or flash module protects writes in flight.
md: portable between machines, visible to the kernel, the standard for software RAID.
LVM RAID (lvcreate --type raid1 -m1) uses the md code inside LVM, so it is managed with LVM commands.
In the cloud: EBS volumes are already replicated inside their Availability Zone. RAID 0 across volumes adds throughput. AWS advises against RAID 5 and 6 on EBS, because parity writes consume the volumes' IOPS.
Measuring I/O
iostat, column by column
bash
iostat -xz 1 # extended stats, hide idle devices, every second
Column
Meaning
Read it as
r/s, w/s
Completed requests per second
IOPS, compare with the volume's limit
rkB/s, wkB/s
Throughput
Compare with the throughput limit
r_await, w_await
Average time per request, in ms, queue included
Latency the application feels
aqu-sz
Average queue length
Sustained values above the device's parallelism mean saturation
%util
Time the device had at least one request in flight
Meaningful on a single disk, misleading on NVMe and cloud volumes
On NVMe and EBS, %util can read 100% while the device still has headroom, because it serves many requests in parallel. Use latency (await) and the volume's IOPS and throughput limits to judge saturation. On EC2, check the volume's CloudWatch metrics too, and the instance's EBS bandwidth limit, which is separate from the volume's.
Who is doing it
bash
pidstat -d 1 # read and write kB/s per process
iotop -oPa # accumulated I/O per process (needs root)
ps -eo pid,stat,wchan:20,comm | awk '$2 ~ /D/' # processes stuck in uninterruptible I/O wait
Processes in state D count toward the load average. A high load with idle CPUs usually means blocked I/O, not compute.
none suits NVMe and most virtual disks, because the device or hypervisor already reorders requests. mq-deadline helps rotating disks and SATA SSDs. Make a change persistent with a udev rule or a tuned profile, not with an echo in rc.local.
Without --direct=1 you benchmark the page cache. Never point fio at a raw device that holds data. A write test against /dev/sdb destroys whatever is on it.
Free space on SSDs
fstrim.timer trims mounted filesystems weekly, so the SSD or thin pool knows which blocks are free. That is usually better than the discard mount option. Check it with systemctl status fstrim.timer, or run it once with fstrim -av.
Network storage and automount
NFS client
bash
dnf install nfs-utils # RHEL family
apt install nfs-common # Debian and Ubuntu
mount -t nfs4 -o vers=4.2 files.example.net:/exports/projects /mnt/projects
nfsstat -m # options actually negotiated for each NFS mount
hard, the default, retries forever, so processes hang in D state while the server is away and continue when it returns. soft returns errors after retrans attempts, and that can corrupt application data. Keep hard for anything that writes.
NFSv4 needs only TCP 2049. NFSv3 also needs rpcbind (111) and the mountd and statd ports, which matters for firewalls and security groups.
showmount -e server only works against NFSv3 servers. For v4, mount the pseudo-root (server:/) and look.
Root squash maps root on the client to nobody on the server. A "Permission denied" for root on an NFS share is usually this, not a bug.
systemctl enable --now autofs, then ls /mnt/auto/alpha triggers the mount. The wildcard line maps any key to the export of the same name. With an indirect map, ls /mnt/auto is empty until a key is accessed, which is normal. Home directories from a central server are the classic case.
x-systemd.automount in fstab gives the same on-first-access behaviour for a single mount without autofs.
The LUN appears as a new SCSI disk, with lsblk and /dev/disk/by-path/ip-.... Mount it with _netdev, and use multipath (multipathd, /etc/multipath.conf) when there is more than one network path.
RHEL storage extras: Stratis and VDO
Stratis manages pools and XFS filesystems with thin provisioning and snapshots through one CLI (stratis pool create, stratis fs create). VDO adds deduplication and compression. On RHEL 9 it is an LVM volume type (lvcreate --type vdo). Both are worth knowing exist. Neither replaces understanding the LVM and XFS layers underneath.
Incidents
Each incident follows the order you would work in: confirm the symptom, narrow down the layer, fix, verify.
A database volume is 100% full
Symptom. PostgreSQL stops accepting writes: "could not extend file ... No space left on device".
df -hT /var/lib/pgsql; df -i /var/lib/pgsqlConfirm it is blocks, not inodes, and which device holds the path.
lsblk; vgsAn LV with free extents in its VG can grow in seconds.
lvextend -r -L +20G vg_data/lv_pgsqlGrow the LV and the filesystem in one step, online.
df -h /var/lib/pgsqlVerify from the filesystem view, not just lvs.
Root cause. WAL growth after a replica fell behind, plus no alert below 85% used.
How to explain it
I check df and df -i so I know it is blocks and which device. If the VG has free extents, lvextend -r grows the LV and the filesystem online in one command. Then I find what grew, here WAL retained for a lagging replica, and add an alert at a threshold that leaves time to act.
cat /proc/mdstat; mdadm --detail /dev/md0Identify the failed member and confirm the other one is active and in sync.
smartctl -a /dev/sdb; dmesg -T | grep -i sdbMedia errors or a dead link: decide whether the disk is really bad.
mdadm --manage /dev/md0 --remove /dev/sdb1Take the failed member out before the swap.
sgdisk -R /dev/sdb /dev/sdc && sgdisk -G /dev/sdbAfter the swap, copy the healthy partition table and randomize GUIDs.
mdadm --manage /dev/md0 --add /dev/sdb1; watch cat /proc/mdstatStart the rebuild and watch it reach [UU].
Root cause. A member disk accumulated reallocated sectors and was kicked from the array by the kernel.
How to explain it
With one mirror left, the priority is to avoid a second failure: I confirm which member failed and that the survivor is healthy, check SMART, remove the failed member, replace it, clone the partition table and add it back. I watch the rebuild, and I make sure mdadm monitoring is alerting, because a degraded array that nobody notices is the real failure.
The volume was resized but df shows the old size
Symptom. The EBS volume was modified from 20 GiB to 50 GiB. df -h / still says 20G.
lsblk /dev/nvme0n1The disk is already 50G: the partition and the filesystem are the layers left behind.
growpart /dev/nvme0n1 1Grow the partition into the new space. Mind the space between growpart and the partition number.
xfs_growfs -d /Grow XFS by its mount point. ext4 would use resize2fs on the partition.
df -h /Verify from the filesystem.
Root cause. Modifying the volume only changes the block device. Each layer above has to be grown.
How to explain it
Modifying an EBS volume only resizes the block device. I check lsblk to see which layer is behind, grow the partition with growpart, then the filesystem, xfs_growfs on the mount point for XFS, resize2fs for ext4, plus pvresize and lvextend if LVM sits in between. All of it online.
Several filesystems turned read-only at once
Symptom. Three unrelated mounts report I/O errors and XFS shut down. They all sit on the same VG.
lvs -a -o lv_name,pool_lv,data_percent,metadata_percent vg_appA thin pool at 100% data or metadata fails writes for every thin LV in it.
vgs vg_appCheck for free extents to grow the pool.
lvextend -L +50G vg_app/pool; lvextend --poolmetadatasize +1G vg_app/poolGive the pool room, data and metadata as needed.
umount /srv/tenant1; xfs_repair /dev/vg_app/lv_tenant1; mount /srv/tenant1XFS that shut down needs an unmount, a check and a mount.
grep -E "thin_pool_autoextend_(threshold|percent)" /etc/lvm/lvm.confTurn on autoextend and alerting so it cannot happen silently again.
Root cause. The thin LVs were overcommitted 3:1 and the pool had no autoextend and no alert.
How to explain it
Several filesystems failing together on one VG makes me look at shared layers, and a thin pool is the usual one. I check data and metadata percent, extend the pool, repair the filesystems that shut down, and then fix the process: autoextend, alerts at 80%, and a limit on how much we overcommit.
A moved disk shows no volume group (RHEL 9)
Symptom. A data disk from a retired server is attached. lsblk shows it with LVM2_member, but vgs prints nothing.
lsblk -f /dev/sdc; pvsThe signature is there and pvs ignores it: the device is being filtered, not missing.
lvmdevicesThe RHEL 9 devices file lists the devices LVM may use. The new disk is not in it.
vgimportdevices vg_oldAdd the VG's devices to the devices file.
vgchange -ay vg_old; lvs vg_oldActivate and check. Rename with vgrename if the VG name clashes.
Root cause. Since RHEL 9, LVM uses only devices listed in /etc/lvm/devices/system.devices.
How to explain it
If lsblk shows LVM2_member but pvs does not, LVM is filtering the device. On RHEL 9 that is the devices file. I add the disk with lvmdevices --adddev or vgimportdevices, activate the VG, and check for name or UUID clashes with existing VGs before mounting.
Cheat sheet
Inspect
Command
What it does
lsblk -o NAME,TYPE,SIZE,FSTYPE,UUID,MOUNTPOINTS
The full stack as a tree
findmnt -T /path
Filesystem that holds a path
df -hT; df -i
Space and inodes per filesystem
du -xh --max-depth=1 /var | sort -h
Largest directories, one filesystem only
blkid
UUIDs, labels and types
Partitions and growth
Command
What it does
parted -s /dev/sdb mklabel gpt mkpart data xfs 1MiB 100%
Pick an answer to see the explanation. Your best score is saved in this browser.
Interview questions
Open questions. Try your own answer out loud, then compare with the model answer, written in English as you would give it in an interview.
A filesystem is full in production. Walk me through it.
Model answer
I identify the filesystem behind the path with findmnt and check both df -h and df -i, because blocks and inodes fail differently. If df and du disagree, I look for deleted files still held open with lsof +L1. For an immediate fix I grow it if the layer below allows, lvextend -r with free extents, growpart and xfs_growfs on a cloud volume, or I clear something safe like rotated logs. Then I find what grew and add an alert that fires early enough to act.
How would you replace a failed disk in a software RAID 1 without downtime?
Model answer
Confirm with mdadm --detail which member failed and that the other one is active and in sync. Mark it failed if the kernel has not, remove it, swap the disk, copy the partition table from the healthy member with sgdisk -R and new GUIDs with -G, then mdadm --add. I watch /proc/mdstat until it shows [UU]. If the array holds /boot or root, I also install the boot loader on the new disk, so the server can still boot from either one.
When would you choose RAID 10 over RAID 5?
Model answer
For write-heavy or latency-sensitive workloads like databases, because RAID 5 pays a read-modify-write penalty for parity on small writes. Also with large disks: a RAID 5 rebuild reads every surviving disk, and a second error during that window loses the array. RAID 10 rebuilds by copying one mirror. The price is capacity, half the raw space.
Explain LVM snapshots and their risks.
Model answer
A classic snapshot is copy-on-write: the first write to each origin block copies the old block into the snapshot area. It is cheap to create and good for a consistent backup or a rollback point before an upgrade. Risks: write performance on the origin drops while it exists, and if the snapshot area fills up the snapshot becomes invalid. Thin snapshots avoid the fixed area but share the pool, so the pool must be monitored. And a snapshot on the same disks is not a backup.
An application says the disk is slow. How do you prove or disprove it?
Model answer
I go layer by layer. pidstat -d tells me which process does the I/O. iostat -xz gives per-device latency, IOPS and throughput, and I compare those with the device or EBS limits, including the instance bandwidth limit. On NVMe I do not trust %util alone. I check for D-state processes and the load average, and the page cache dirty numbers in meminfo. If latency is low and limits are far, the bottleneck is elsewhere, often locking or the application itself.
What changed with LVM on RHEL 9 that can break a migration?
Model answer
The devices file. LVM only scans the devices listed in /etc/lvm/devices/system.devices, so a disk attached from another host or restored from a snapshot is ignored even though lsblk shows the LVM signature. You add it with lvmdevices --adddev or vgimportdevices. It prevents LVM from grabbing devices it should not, for example guest disks on a hypervisor host.