Linux Labs EspañolES

Modules 3

Storage: disks, LVM and RAID

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.

7 sections5 incidents10 questions7 labs

The path of a write(), layer by layer

  1. Applicationwrite() · fsync()pidstat -d
  2. VFSdentry · inode cachestrace -e trace=file
  3. Page cachedirty pages · writebackgrep -i dirty /proc/meminfo
  4. FilesystemXFS · ext4 · journaldf -hT · df -i
  5. Device mapper · mdLVM · LUKS · multipath · RAIDlsblk · dmsetup ls --tree
  6. Block layerblk-mq · scheduleriostat -xz 1
  7. Drivernvme · virtio · scsidmesg -T
  8. DeviceNVMe · EBS · SASsmartctl · nvme smart-log
  1. The application calls write(). It returns as soon as the kernel has the data, not when the data is on disk.
  2. VFS resolves the path to an inode, checks permissions and hands the call to the right filesystem.
  3. The data lands in the page cache as dirty pages. Writeback threads flush them later, or now if the program calls fsync().
  4. The filesystem allocates blocks and journals the metadata change. ENOSPC can surface here, on writeback, long after write() returned.
  5. Device mapper and md translate the logical block to one or more real devices: LVM extents, an encrypted sector, mirrored copies.
  6. The block layer merges and queues requests, one hardware queue per CPU on NVMe. Latency and queue depth are measured here.
  7. The driver submits the command to the controller: NVMe, virtio in a VM, or an EBS volume on a Nitro card.
  8. 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

QuestionLayerTool
Who is writing?Processpidstat -d 1, iotop
Is the cache absorbing it?Page cachefree -h, grep -i dirty /proc/meminfo
Is the filesystem full?Filesystemdf -hT, df -i
Is the device saturated?Block layeriostat -xz 1
Is the hardware failing?Devicesmartctl -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:

PathBased onSurvives
/dev/disk/by-uuid/Filesystem UUIDReboots and device moves. A reformat changes it
/dev/disk/by-partuuid/GPT partition GUIDA reformat of the filesystem
/dev/disk/by-id/Model and serial numberReboots. On EC2 the serial is the EBS volume ID
/dev/disk/by-path/Bus positionOnly 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

XFSext4
Default onRHEL familyDebian, Ubuntu
GrowOnline, by mount point: xfs_growfs /mntOnline or offline: resize2fs /dev/X
ShrinkNot possible: back up and recreateOffline only: e2fsck -f, then resize2fs /dev/X 20G
InodesAllocated dynamicallyFixed at mkfs, and can run out
Repairxfs_repair on an unmounted devicee2fsck -f on an unmounted device
Reserved spaceNone5% for root by default, tune2fs -m 1 to lower it
Inspectxfs_info /mnttune2fs -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.

bash
mkfs.xfs -L data /dev/vg_app/lv_data
mkfs.ext4 -L logs -m 1 /dev/vg_app/lv_logs
xfs_repair -n /dev/vg_app/lv_data       # dry run: report, change nothing

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.

fstab, one field at a time

text
UUID=6f1c...e2  /var/lib/pgsql  xfs  defaults,noatime,nofail  0 0
<device>        <mount point>   <type> <options>              <dump> <fsck pass>
  • Use UUID= or LABEL=, never /dev/sdX.
  • 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
  1. pvcreate /dev/sdb /dev/sdc Each disk gets an LVM label and is split into physical extents, 4 MiB each by default.
  2. vgcreate vg_app /dev/sdb /dev/sdc The volume group pools the extents of both disks. Its free space is the sum.
  3. 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.
  4. 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.
  5. 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.
  6. vgextend vg_app /dev/sdd The VG ran low, so a third disk joins it. Nothing is unmounted.
  7. 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.

bash
lvcreate --type thin-pool -L 100G -n pool vg_app
lvcreate -V 300G --thin -n lv_tenant1 vg_app/pool
lvs -o lv_name,data_percent,metadata_percent vg_app

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
LevelMinimum disksUsable capacitySurvivesWrite cost
RAID 02n × diskNo failuresNone, fastest
RAID 121 × diskn − 1 failuresEvery write goes to every disk
RAID 53(n − 1) × disk1 failureRead-modify-write for parity
RAID 64(n − 2) × disk2 failuresTwo parity blocks per stripe
RAID 104n / 2 × disk1 per mirror pairMirror 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.

Create and persist an array

bash
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
cat /proc/mdstat                                   # resync progress
mdadm --detail /dev/md0                            # state, members, UUID
mdadm --detail --scan >> /etc/mdadm.conf           # RHEL family
mdadm --detail --scan >> /etc/mdadm/mdadm.conf     # Debian and Ubuntu, then: update-initramfs -u

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
ColumnMeaningRead it as
r/s, w/sCompleted requests per secondIOPS, compare with the volume's limit
rkB/s, wkB/sThroughputCompare with the throughput limit
r_await, w_awaitAverage time per request, in ms, queue includedLatency the application feels
aqu-szAverage queue lengthSustained values above the device's parallelism mean saturation
%utilTime the device had at least one request in flightMeaningful 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.

Scheduler and queue

bash
cat /sys/block/nvme0n1/queue/scheduler       # [none] mq-deadline kyber bfq
cat /sys/block/sda/queue/nr_requests

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.

Benchmark the right thing

bash
fio --name=randread --filename=/data/fio.test --size=4G --rw=randread --bs=4k \
    --iodepth=32 --ioengine=libaio --direct=1 --runtime=60 --time_based --group_reporting

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

fstab line:

text
files.example.net:/exports/projects  /mnt/projects  nfs4  _netdev,nofail,x-systemd.automount,vers=4.2  0 0
  • 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.

autofs: mount on demand

text
# /etc/auto.master.d/projects.autofs
/mnt/auto  /etc/auto.projects  --timeout=300

# /etc/auto.projects  (indirect map: key, options, location)
alpha   -fstype=nfs4,rw   files.example.net:/exports/alpha
*       -fstype=nfs4,rw   files.example.net:/exports/&

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.

iSCSI in two commands

bash
iscsiadm -m discovery -t sendtargets -p 198.51.100.20
iscsiadm -m node -T iqn.2026-01.net.example:storage.lun1 -p 198.51.100.20 --login

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".

  1. df -hT /var/lib/pgsql; df -i /var/lib/pgsqlConfirm it is blocks, not inodes, and which device holds the path.
  2. lsblk; vgsAn LV with free extents in its VG can grow in seconds.
  3. lvextend -r -L +20G vg_data/lv_pgsqlGrow the LV and the filesystem in one step, online.
  4. 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.

RAID 1 is degraded

Symptom. Monitoring reports md0 degraded. /proc/mdstat shows [U_].

  1. cat /proc/mdstat; mdadm --detail /dev/md0Identify the failed member and confirm the other one is active and in sync.
  2. smartctl -a /dev/sdb; dmesg -T | grep -i sdbMedia errors or a dead link: decide whether the disk is really bad.
  3. mdadm --manage /dev/md0 --remove /dev/sdb1Take the failed member out before the swap.
  4. sgdisk -R /dev/sdb /dev/sdc && sgdisk -G /dev/sdbAfter the swap, copy the healthy partition table and randomize GUIDs.
  5. 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.

  1. lsblk /dev/nvme0n1The disk is already 50G: the partition and the filesystem are the layers left behind.
  2. growpart /dev/nvme0n1 1Grow the partition into the new space. Mind the space between growpart and the partition number.
  3. xfs_growfs -d /Grow XFS by its mount point. ext4 would use resize2fs on the partition.
  4. 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.

  1. 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.
  2. vgs vg_appCheck for free extents to grow the pool.
  3. lvextend -L +50G vg_app/pool; lvextend --poolmetadatasize +1G vg_app/poolGive the pool room, data and metadata as needed.
  4. umount /srv/tenant1; xfs_repair /dev/vg_app/lv_tenant1; mount /srv/tenant1XFS that shut down needs an unmount, a check and a mount.
  5. 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.

  1. lsblk -f /dev/sdc; pvsThe signature is there and pvs ignores it: the device is being filtered, not missing.
  2. lvmdevicesThe RHEL 9 devices file lists the devices LVM may use. The new disk is not in it.
  3. vgimportdevices vg_oldAdd the VG's devices to the devices file.
  4. 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

CommandWhat it does
lsblk -o NAME,TYPE,SIZE,FSTYPE,UUID,MOUNTPOINTSThe full stack as a tree
findmnt -T /pathFilesystem that holds a path
df -hT; df -iSpace and inodes per filesystem
du -xh --max-depth=1 /var | sort -hLargest directories, one filesystem only
blkidUUIDs, labels and types

Partitions and growth

CommandWhat it does
parted -s /dev/sdb mklabel gpt mkpart data xfs 1MiB 100%GPT label and one aligned partition
partprobe /dev/sdb && udevadm settleRe-read the partition table
growpart /dev/nvme0n1 1Grow a partition to the end of the disk
sgdisk -R /dev/new /dev/healthy && sgdisk -G /dev/newClone a GPT table to a replacement disk

Filesystems

CommandWhat it does
mkfs.xfs -L data /dev/vg/lvCreate XFS with a label
xfs_growfs /mountpointGrow XFS online (no shrink)
xfs_repair -n /dev/vg/lvCheck XFS without changing it, unmounted
resize2fs /dev/vg/lvGrow ext4, online
tune2fs -l /dev/vg/lv | grep -i -E "inode|reserved"ext4 inode and reserve settings
findmnt --verify --verboseValidate fstab

LVM

CommandWhat it does
pvs; vgs; lvs -a -o +devicesOverview with physical placement
lvextend -r -L +10G vg/lvGrow LV and filesystem together
vgextend vg /dev/sddAdd a disk to a VG
pvmove /dev/sdbEvacuate a PV online
lvcreate -s -L 5G -n snap vg/lvCopy-on-write snapshot
lvconvert --merge vg/snapRoll the origin back to the snapshot
lvs -o lv_name,data_percent,metadata_percentThin pool fill level
lvmdevices --adddev /dev/sdXRHELAllow a device (RHEL 9 devices file)
vgcfgrestore --list vgMetadata versions you can restore

RAID

CommandWhat it does
cat /proc/mdstatArray state and rebuild progress
mdadm --detail /dev/md0Members, state, UUID
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1Create a mirror
mdadm --manage /dev/md0 --remove /dev/sdb1Remove a failed member
mdadm --manage /dev/md0 --add /dev/sdd1Add a replacement and start the rebuild
mdadm --detail --scanLines for mdadm.conf

Performance

CommandWhat it does
iostat -xz 1Latency, IOPS, throughput per device
pidstat -d 1I/O per process
cat /sys/block/nvme0n1/queue/schedulerActive I/O scheduler
fstrim -avTrim every mounted filesystem once

Network storage

CommandWhat it does
nfsstat -mNegotiated NFS options
mount -t nfs4 server:/export /mntMount NFSv4
automount -mShow the maps autofs loaded
iscsiadm -m session -P 3iSCSI sessions and their disks

Quiz

Pick an answer to see the explanation. Your best score is saved in this browser.

1You run lvextend -L +10G on an LV holding XFS, without -r. What does df show?
Show the answer

Answer: The old size, until xfs_growfs runs. The block device grew, the filesystem did not. -r, or xfs_growfs on the mount point, completes the job.

2Which filesystem operation is impossible on XFS?
Show the answer

Answer: Shrink. XFS can only grow. To make it smaller you back up, recreate and restore. ext4 can shrink while unmounted.

3df shows 40% used, yet creating files fails with "No space left on device" on ext4. Most likely cause?
Show the answer

Answer: Inodes exhausted. ext4 fixes the inode count at mkfs time. Millions of small files exhaust inodes while blocks remain. df -i shows it.

4A 4-disk RAID 6 array. How many disks can fail without data loss, and what is the usable capacity?
Show the answer

Answer: 2 failures, 2 disks. RAID 6 stores two parity blocks per stripe: n − 2 disks of capacity, any two disks can fail.

5Why should an fstab entry use UUID= instead of /dev/nvme1n1?
Show the answer

Answer: Kernel device names depend on discovery order and can change between boots. Attach order and probe timing decide sdX and nvmeXn1 names. The filesystem UUID travels with the data.

6A thin pool reaches 100% data usage. What happens?
Show the answer

Answer: Writes that need new blocks fail on every thin LV in the pool. Thin LVs share the pool. When it is full, every thin LV fails writes to unallocated blocks, and filesystems often shut down. Autoextend only works if the VG has free extents.

7On an NVMe volume, iostat shows %util at 100% and w_await at 0.4 ms. Is the device saturated?
Show the answer

Answer: Not necessarily: NVMe serves requests in parallel, so judge by latency and the IOPS or throughput limits. %util only says at least one request was in flight. Low await means requests complete quickly, so there is headroom.

8You mount an LVM snapshot of an XFS volume next to its origin and mount fails. What option is missing?
Show the answer

Answer: nouuid. The snapshot carries the same XFS UUID as the origin, and XFS refuses to mount two filesystems with the same UUID unless you pass nouuid.

9Which statement about RAID 1 is true?
Show the answer

Answer: It protects against a disk failure but copies deletions and corruption to both disks. Mirroring is availability, not recoverability. Anything written, including mistakes, goes to every member.

10An NFS server goes away. Clients mounted with the default options do what?
Show the answer

Answer: Block processes in D state and retry until the server returns. hard is the default: safe for data, but processes hang. soft returns errors and risks silent corruption for writers.

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.

Labs

Sources and further reading