Linux internals & storage
The kernel-side subsystems you reach for when ordinary userspace tools stop explaining things: flexible storage with LVM, and in-kernel observability through eBPF and the tracing toolchain. Interviewers go here for senior systems and SRE roles, where the expectation is that you can see inside the kernel rather than only around it.
on this pageshowhide
guide
overview
~1 minThis hub covers the parts of Linux you reach for once `top`, `df` and the application's own logs stop explaining what is happening: the storage layer that sits between a filesystem and its disks, and the tools that let you watch the kernel at work on a live host. Interviewers bring it into senior systems, SRE and platform rounds because the answers separate people who operate Linux from the outside from people who can reason about what the kernel is doing on their behalf. The hub has three sections. [LVM](/topics/os-lvm) is Linux's volume manager: how disks are pooled, carved into volumes, grown and moved while services keep running, and snapshotted before something risky. [eBPF](/topics/os-ebpf) is the mechanism for running small, kernel-checked programs at hooks across the system, and it underpins much of modern tracing, packet processing and runtime security. [Tracing and profiling tools](/topics/os-tracing-diagnostics) covers the classic instruments, `strace`, `ltrace` and `perf`, that answer "what is this process doing right now?" Junior questions check the layer model: which command touches which layer, and what a tool can see. Senior and principal questions turn into incidents and trade-offs, such as a full snapshot, a tracer that slows production, or a filter that loads but never runs where you expected. Start with LVM's three layers and the classic tracers, then move to eBPF, which takes the tracing ideas inside the kernel.
primer
### Storage is a stack of layers A filesystem sits on a block device, and under LVM that block device is a logical volume built by device-mapper from extents on one or more disks. Each layer keeps its own idea of size. Most LVM questions come down to naming which layer you changed and which one still has to hear about it. ### Growing is cheap; shrinking is not Adding capacity and moving data between disks happen online in LVM. Taking capacity away needs the filesystem's cooperation and on some filesystems is impossible. That asymmetry shapes provisioning policy, and interviewers reward candidates who leave room to grow. ### A snapshot shares the origin's fate LVM snapshots are cheap because they depend on the origin volume for everything that has not changed. That makes them a stable source to copy from and a quick rollback point, not a backup. Classic and thin snapshots pay for this differently, and each fails in its own way when its space runs out. ### Every observer costs something Each tracing tool sits at a different depth and charges a different price: a ptrace-based tracer stops its target on every event it traces, a sampling profiler interrupts on a timer, and an eBPF program runs inline and can summarise in the kernel. Pick the instrument by what it sees and what it costs on a busy host. ### eBPF is verified code in the kernel An eBPF program is checked by the **verifier** before it may run, and its program type decides where it can attach. Maps hold its state and carry results to user space. The verifier explains most of the odd constraints candidates meet: a small stack, bounded loops, null checks, and a fixed menu of helpers. ### Stability is a property of the hook Some attachment points are a declared interface; others are internal functions that the next kernel may rename or inline. Tooling splits the same way, between compiling on every host and shipping one binary that adapts to the kernel it lands on. Fleet questions reward choosing the stable side on purpose.
- Physical volume (PV)
- A disk or partition initialised for LVM, with a label and metadata area, whose space is divided into extents that a volume group can allocate.
- Volume group (VG)
- A pool formed from one or more physical volumes. Logical volumes are allocated from its free extents, and it is the unit you extend by adding disks.
- Logical volume (LV)
- A block device carved from a volume group's extents. Filesystems and databases sit on it, unaware of which physical disks hold its data.
- Thin pool
- An LVM volume that allocates blocks on first write to the thin volumes it backs, so their combined virtual size can exceed the real space.
- Copy-on-write snapshot
- A point-in-time view of a volume that stores only the blocks changed since it was taken and reads unchanged blocks from the origin.
- ptrace
- The kernel interface that lets one process stop, inspect and resume another. Debuggers and strace are built on it, which is why they slow the target.
- eBPF verifier
- The in-kernel checker that analyses every eBPF program at load time and refuses any it cannot prove safe and terminating.
- eBPF map
- A kernel-resident data structure that eBPF programs read and write, and that user space reaches through file descriptors. It holds state and carries results out.
- kprobe and tracepoint
- Two kernel hook styles: a kprobe instruments almost any kernel function dynamically, while a tracepoint is a fixed, named instrumentation point placed in the source.
- XDP
- eXpress Data Path, an eBPF hook at the earliest point of packet receive, normally inside the driver, that can drop, pass or redirect packets before the normal stack sees them.
- BTF and CO-RE
- BPF Type Format describes kernel types; Compile Once, Run Everywhere uses it so one compiled eBPF binary adapts to different kernels at load time.
The three sections meet on one host, around one question: where is the time, or the space, going? A request from an application crosses the system-call boundary, passes through a filesystem, lands on a logical volume, and device-mapper turns it into I/O on real disks. Each tool in this hub watches a different stretch of that path. - **LVM** owns the lower half. It decides which disks hold a volume's extents, so capacity, striping, snapshots and disk evacuation are questions about that mapping. - **strace and ltrace** sit at the top, at the system-call and library-call boundaries of a single process. They show what a program asked for and what came back. - **perf** samples what the CPU is executing, user code and kernel alike, and reads the hardware's performance counters. - **eBPF** can attach at most of these points and beyond, from a syscall entry to a block-layer event or a network driver, and aggregate in the kernel instead of copying every event out. An answer that names the layer first and the tool second is usually the one interviewers want. The same disk-heavy service looks different at each depth: ```bash # which volume, and which disks under it lsblk -o NAME,TYPE,SIZE,MOUNTPOINT # what the process asks the kernel for (ptrace: costly on a busy host) strace -f -p "$PID" -e trace=%file # what actually reaches the block layer, counted in the kernel bpftrace -e 'tracepoint:block:block_rq_issue { @[comm] = count(); }' ``` The first line reads the layout, the second watches one process from outside at real cost, and the third summarises across the machine with little overhead.
- Physical Volumes, Volume Groups & Logical Volumes →
The three LVM layers and extents; every resize, snapshot and migration question assumes this model.
- Resizing & Migration →
Growing volumes, adding disks and evacuating a failing one online: the routine operations interviewers walk through step by step.
- strace and ltrace →
The system-call boundary and the simplest live tracer, plus what attaching it costs a production process.
- perf and CPU profiling →
Sampling, call stacks, flame graphs and hardware counters, for when the question becomes where CPU time goes.
- Verifier and Safety Model →
Why eBPF programs are shaped the way they are; most later eBPF constraints trace back to the verifier.
- Tracing and Observability →
Putting eBPF to work on observability, where most interview scenarios for it land.
Growing a logical volume and assuming the filesystem grew with it; the two layers are resized separately unless you ask for both.
Shrinking in the wrong order, or planning to shrink XFS at all; see Resizing & Migration before touching
lvreduce.Calling an LVM snapshot a backup: it lives on the same disks as its origin and is only useful while the origin survives.
Creating a snapshot or thin pool without watching how full it gets; running out of space is when both fail, and they fail badly.
Attaching
straceto a hot production process without mentioning its overhead, or without naming a lower-cost alternative.Reading a flame graph's horizontal axis as time; width means share of samples, and left-to-right order carries no timeline.
Building a fleet tool on kprobes of internal kernel functions and not expecting it to break after a kernel upgrade.
Assuming an XDP program is fast because it loaded; if it fell back to generic mode, it runs later in the path with little gain.
This guide assumes a current long-term kernel in the 6.x range and LVM2. Most LVM behaviour discussed here has been stable for years; eBPF is where the kernel version changes the answer, and interviewers on mixed fleets ask about it. - **5.3** let the verifier accept loops it can bound, ending the era of mandatory unrolling. - **5.5** added the BPF trampoline behind fentry and fexit programs. - **5.7** added BPF LSM programs. - **5.8** introduced the BPF ring buffer and split eBPF and perf privileges into `CAP_BPF` and `CAP_PERFMON`, so tooling no longer needs full `CAP_SYS_ADMIN`. - **5.17** added the `bpf_loop()` helper. Kernels that lack BTF information cannot run CO-RE binaries without outside help, so "which kernel, built how" is a fair first question before any eBPF answer. When a feature is newer than the oldest kernel in the fleet, say so and name the fallback.
**Storage.** LVM is a volume manager layered under a separate filesystem. ZFS and Btrfs fold pooling, snapshots and checksums into the filesystem itself, at the cost of a different operational model. Software RAID with mdadm and hardware RAID provide redundancy and are often stacked under LVM rather than replacing it. **Observability and packets.** eBPF is the base of bpftrace and bcc for ad hoc tracing, and is used by products such as Cilium for networking and Falco for runtime security. For new tooling it has largely replaced kernel-module approaches such as SystemTap, because the verifier makes in-kernel code safe to load on production hosts. DTrace, from Solaris, is the ancestor most dynamic-tracing ideas are compared to. For packet processing, DPDK bypasses the kernel for raw throughput, while XDP keeps the kernel and its tooling in play. Choosing between them is a principal-level question.
explore
- LVM17 questions
- Snapshots & Thin Provisioning7 questions
- Resizing & Migration5 questions
- eBPF33 questions
- Verifier and Safety Model6 questions
- Program Types and Hooks5 questions
- Maps and Helpers5 questions
- Tracing and Observability5 questions
- Networking: XDP and tc6 questions
- Tooling: libbpf and bcc6 questions
- Tracing & profiling tools10 questions
- strace and ltrace5 questions
- perf and CPU profiling5 questions
questions
page 2 of 2How does a thin snapshot of an LVM thin logical volume differ from a classic `lvcreate -s -L` snapshot in the way it stores data, and why can you keep dozens of thin snapshots but not dozens of classic ones?
basics
~20 sA classic LVM snapshot owns a fixed copy-on-write area and preserves old chunks by copying them into it. A thin snapshot just shares block references in the thin pool: a write allocates a new pool block, nothing is copied, and the cost does not grow with the number of snapshots.
As an ordinary non-root user on a Linux host, `perf record` fails with a permission error about performance monitoring operations. Which sysctl governs that, what do its values mean, and what additionally blocks perf inside a container?
basics
~10 sThe sysctl is kernel.perf_event_paranoid, exposed at /proc/sys/kernel/perf_event_paranoid. Higher values restrict unprivileged use: 2 permits user-space measurement only, 1 also allows kernel profiling, -1 removes restrictions. Granting CAP_PERFMON is the privileged alternative.
A Linux daemon is already running and burning most of its time in the kernel. What does `strace -c -p <pid>` give you that a full trace does not, and how do you read its output?
basics
~20 sstrace -c aggregates instead of printing every call: one row per system call with call count, error count and time. It answers which syscalls dominate and which fail, at the cost of losing the sequence in which they happened.
An eBPF program counts events by looking a key up in a BPF_MAP_TYPE_HASH and doing (*val)++, and under load the totals come out too low. What is wrong, and what do __sync_fetch_and_add() and BPF_MAP_TYPE_PERCPU_HASH each change about it?
basics
~20 sIncrementing a value fetched from a shared map is a non-atomic read-modify-write, so CPUs running the hook concurrently overwrite each other's counts. __sync_fetch_and_add() makes the update atomic; a per-CPU map gives each CPU its own value, and user space sums across CPUs.
In an XDP-based L4 load balancer, what is the difference between returning XDP_TX and returning XDP_REDIRECT for a forwarded packet, and why do such designs typically encapsulate the packet and use direct server return rather than plain NAT?
basics
~20 sXDP_TX resends the packet out the interface it arrived on; XDP_REDIRECT hands it to a different target through a redirect map. Encapsulation with direct server return lets backends reply straight to the client, so only the request half crosses the load balancer.
You attach an XDP drop program to a 25 GbE Linux server's interface. The filter works, but throughput and CPU use are no better than the iptables rule it replaced, and `ip link show` reports the attachment as xdpgeneric. What are XDP's three attach modes, and what has happened here?
basics
~20 sXDP attaches in native mode inside the driver, generic mode in the shared kernel receive path after the sk_buff is allocated, or offloaded onto a capable NIC. Generic mode is a correctness fallback with none of the performance benefit — the driver did not support native XDP.
A colleague loaded an XDP program onto a production interface from a terminal that has since been closed, and traffic is still being affected. Why do some eBPF attachments survive the process that created them while others vanish with it, and how would you find and remove this one?
basics
~20 sAttachments made through a bpf_link end when the last file descriptor to that link closes, while netlink XDP attachments, tc filters and cgroup attachments hold their own kernel reference and outlive the loader. Those have to be detached explicitly.
In eBPF, fentry and fexit programs (BPF_PROG_TYPE_TRACING) can target many of the same kernel functions as kprobe and kretprobe programs. How do they attach differently, and what does an fexit program see that a kretprobe cannot?
basics
~20 sfentry and fexit programs attach through a BPF trampoline at the compiler-inserted patch site and read typed arguments derived from BTF. An fexit program sees the function's arguments and its return value together; a kretprobe sees only the return.
A libbpf CO-RE binary that works on a current Ubuntu server fails to load on an older Linux host, and `/sys/kernel/btf/vmlinux` does not exist there. What is missing, and what are your options for that host?
basics
~20 sThat kernel was built without CONFIG_DEBUG_INFO_BTF, so it exposes no BTF and libbpf has nothing to resolve the binary's CO-RE relocations against. Options are a kernel built with BTF enabled, supplying an externally generated BTF for that exact kernel, or falling back to a runtime-compiled bcc tool.
Your bpftrace one-liner runs fine as root on a Linux host but fails to load when you run it inside a container, and when you run it from the host against a containerised workload the PIDs and file paths it prints do not match what you see inside the container. Explain both problems and how you would work around each.
basics
~20 sInside a container the loading fails because the bpf and perf_event_open system calls are usually blocked by the default seccomp profile and the required capabilities are dropped. From the host, the PIDs printed are the host's, and the file paths belong to the container's mount namespace, so neither matches what the container shows.
A large eBPF program is rejected with the verifier reporting that it processed too many instructions, even though the program itself is far shorter than the instruction limit. What is the verifier counting, and how do you restructure the program so it loads?
basics
~20 sThe verifier counts instructions it simulates across every reachable path, not instructions in the program, so branches and loops multiply the work. Reduce path explosion: cut branches, help its bounds tracking, move iteration into bpf_loop(), and split logic into independently verified global subprograms or tail calls.
You are adding a new data disk to a Linux server for LVM. Should you run pvcreate on the whole disk (/dev/sdb) or on a partition (/dev/sdb1), and what does each choice cost you?
basics
~20 sBoth work. A whole-disk PV is simpler and self-aligning but leaves no partition table, so other tools and humans can mistake the disk for blank. A partitioned PV advertises its use through the Linux LVM type code and lets the disk be shared, at the cost of an extra layer to manage.
On a Linux server, /dev/sdb is one of three physical volumes in an LVM volume group serving live databases, and it has started logging SMART errors and I/O timeouts. How do you get the data off that disk and remove it from the volume group without downtime?
basics
~20 sConfirm the remaining physical volumes hold enough free extents, then run pvmove /dev/sdb to relocate its extents onto them while the volumes stay online. Finish with vgreduce to drop the disk from the group and pvremove to clear its LVM label.
Before a risky package upgrade you snapshot the Linux server's root-adjacent data volume with `lvcreate -s`. The upgrade goes badly and you want to roll back. What does `lvconvert --merge vg0/snap` do, and why might the rollback not take effect the moment the command returns?
basics
~20 slvconvert --merge schedules the snapshot's preserved contents to be written back over the origin, reverting it to the snapshot's point in time and deleting the snapshot when finished. If the origin is open — mounted or in use — the merge is deferred until the volume is next deactivated and reactivated.
An LVM thin pool created with `lvcreate -L 200G -T vg0/pool` backs thin volumes whose virtual sizes total 800G. What happens to those volumes when the pool's data space — or its metadata space — actually runs out, and how do you keep that from happening?
basics
~20 sOnce the pool has no free blocks, any write needing a new allocation fails or hangs, filesystems on the thin volumes go read-only or corrupt, and metadata exhaustion is worse — the pool goes read-only and needs offline repair. Prevent it with Data%/Meta% alerting, autoextend, and volume group headroom.
A `perf record -g` capture of a production Linux service produces a report where nearly every call stack is only one or two frames deep. Why does frame-pointer unwinding fail, and what do `--call-graph dwarf` and `--call-graph lbr` do differently?
basics
~20 sPlain -g means frame-pointer unwinding, and optimised x86-64 builds usually compile with -fomit-frame-pointer, freeing that register for general use — so there is no chain to walk. --call-graph dwarf copies part of the user stack per sample and unwinds it offline using DWARF debug data; --call-graph lbr uses the CPU's branch records.
Running strace inside a Linux container fails with "ptrace: Operation not permitted" even though the shell is root. What is blocking it, and how would you trace the process anyway?
basics
~20 sRoot inside a container runs with a reduced capability set that normally omits CAP_SYS_PTRACE, so the ptrace attach is refused. Either grant that capability when the container starts, or run strace from the host against the process's host PID.
You need packet filtering and load balancing at close to line rate on commodity Linux servers. How would you decide between an XDP/eBPF datapath and a kernel-bypass framework such as DPDK, and what does each approach cost you?
basics
~20 sDPDK takes the NIC away from the kernel for maximum throughput, at the cost of the whole kernel network stack, its tooling, and dedicated busy-polling cores. XDP stays inside the kernel, slightly slower but selective, interrupt-driven and operable with normal tools. Choose by how much of the traffic is exceptional.
You own the eBPF-based tracing tools for a fleet of Linux servers spanning several kernel versions and distributions. How would you decide between shipping bcc-based tools and libbpf CO-RE binaries, and what would you standardise in the build and distribution pipeline?
basics
~20 sStandardise on libbpf CO-RE binaries for anything shipped, because they need no compiler or headers on production hosts, and keep bcc for ad-hoc work on lab machines. Then fix a minimum kernel and BTF baseline, a pinned build toolchain, and a load-test matrix covering every kernel in the fleet.
Your XDP program on a Linux host is dropping flood packets with XDP_DROP, but `tcpdump -i eth0` on that host shows none of those packets at all. Why can tcpdump not see them, and where does its own filter actually run?
basics
~20 stcpdump reads packets from an AF_PACKET socket that is fed later in the receive path, after the driver has built an sk_buff. Native XDP runs before that, so packets it drops never reach the tap. Count drops in a BPF map instead.
In a libbpf project on Linux, what does `bpftool gen skeleton prog.bpf.o > prog.skel.h` produce, and how does the generated skeleton change the user-space loader code?
basics
~20 sIt generates a C header that embeds the compiled BPF object and declares a struct named after it, with open, load, attach and destroy functions plus typed members for every map, program, link and global variable — replacing hand-written libbpf boilerplate and file loading at runtime.
An LVM logical volume appears on Linux as /dev/vg0/data, /dev/mapper/vg0-data and /dev/dm-2. What is each of those three paths, and how does device-mapper name a volume whose VG or LV name contains a dash?
basics
~20 s/dev/dm-2 is the real device-mapper device node, whose number is assigned at activation and is not stable. /dev/mapper/vg0-data and /dev/vg0/data are udev-created symlinks to it. Dashes inside a VG or LV name are doubled in the /dev/mapper form.
You run `perf stat` against a CPU-bound Linux process and see roughly 0.3 instructions per cycle together with a high cache-miss count. What is that telling you about the workload, and what would an IPC near 3 mean instead?
basics
~20 sLow instructions-per-cycle with heavy cache misses means the CPU is stalling on memory rather than doing work — the fix is data layout and access patterns. A high IPC means the core is genuinely retiring instructions, so the code is doing too much work, and you optimise the algorithm.
On Linux, what does ltrace show that strace does not, and why does ltrace often print nothing useful for a Go binary or a statically linked program?
basics
~20 sltrace traces calls into shared libraries — malloc, strcmp, OpenSSL functions — which never appear in a system-call trace. It works by breakpointing dynamic-linking stubs, so a statically linked or Go binary that makes no such calls gives an empty trace.
A long-running eBPF tool keys a BPF_MAP_TYPE_HASH by connection and never observes some of those connections close, so entries accumulate. What happens once the map reaches max_entries, and what does switching to BPF_MAP_TYPE_LRU_HASH change?
basics
~20 sA BPF hash map has a fixed max_entries; once full, inserting a new key fails with -E2BIG and, if the program ignores the return value, the event is silently dropped. BPF_MAP_TYPE_LRU_HASH instead evicts an approximately least-recently-used entry so inserts keep succeeding.
In eBPF, a cgroup program and a BPF LSM program both sit outside the tracing hooks and both can make the kernel refuse an operation. What does each one attach to, and what does its return value control?
basics
~20 sA cgroup program attaches to a cgroup v2 directory and governs every process inside it; a BPF LSM program attaches to a kernel security hook. In both cases the return value decides whether the kernel allows the operation to proceed.
You want to time a function inside a running user-space application using bpftrace's `uprobe` and `uretprobe` probes. How does a uprobe actually attach to the process, roughly what does each hit cost compared with a kernel tracepoint, and which kinds of binary make this approach unreliable?
basics
~20 sA uprobe patches a breakpoint instruction into a private copy of the target's executable page, so every thread that reaches that address traps into the kernel and runs the BPF program. Each hit costs roughly a microsecond, far more than a tracepoint. Stripped, statically linked, Go and JIT-compiled binaries make it unreliable.
You take an LVM snapshot of a mounted, actively written filesystem on a Linux host. What consistency does the resulting snapshot actually give you, and what does running `fsfreeze -f` on the mount point immediately before the snapshot add?
basics
~20 sThe snapshot is crash-consistent: it looks exactly like the volume would after a power cut, so a journalling filesystem mounts it after replaying its journal, but anything still buffered above the block layer is missing. fsfreeze -f flushes and quiesces the filesystem first, giving a cleanly-shut-down image instead.
Most Linux distributions ship with unprivileged eBPF disabled via kernel.unprivileged_bpf_disabled. If the verifier already proves every program safe, why is unprivileged loading turned off, and how would you decide what privileges to grant eBPF tooling across a fleet?
basics
~20 sThe verifier proves architectural safety, not speculative-execution safety, and it is itself a large piece of attack surface whose bugs have been privilege escalations. Distributions therefore disable unprivileged loading and expect eBPF tooling to run with CAP_BPF plus the capability its program type needs.
When you standardise LVM provisioning across a fleet of Linux servers, how do you decide how much of each volume group to allocate to logical volumes up front rather than leaving extents unallocated?
basics
~20 sAllocate lean and grow on demand. LVM growth is online and cheap, while shrinking is offline at best and impossible on XFS, so unallocated extents are the reversible position. Free extents also give operations like pvmove somewhere to relocate data.
showing 31–60 of 60