Disks#
A “disk” on Linux is a block device. SATA / SCSI / USB drives appear
under /dev/sd*, NVMe drives under /dev/nvme*n*, SD cards under
/dev/mmcblk*, and virtual disks under /dev/vd*. The kernel
exposes them via udev, and lsblk is the standard overview.
Filesystems on top are mounted into the tree at a path, which is what user space actually reads and writes. The block device itself stays out of the application’s view; everything above the mount point looks like ordinary files.
Volumes#
“Volume” on Linux is a soft word. It can mean any of the layers between the raw disk and the mounted filesystem the operator actually reads and writes. The stack is composable, and most production hosts run two or three of these layers in series. Knowing which layer a name refers to (and which tool owns it) is the first step to changing it.
Layer |
Common name |
What it is |
|---|---|---|
Physical disk |
block device |
The hardware (or virtual hardware). |
Partition |
partition |
A contiguous slice of a disk described by an MBR or GPT
partition table. |
Encrypted volume |
LUKS volume, dm-crypt mapping |
A device-mapper target that decrypts on read and encrypts on
write. |
RAID array |
md device |
A device-mapper target that combines several block devices
for redundancy or striping. |
LVM physical / volume group / logical volume |
PV / VG / LV |
Abstracts one or more block devices into a pool (VG) carved
into resizable, named pieces (LVs). |
Btrfs / ZFS subvolume / dataset |
subvolume, dataset |
Filesystem-internal volume managed by the FS itself, not device-mapper. Snapshots and quotas live here. |
Filesystem |
filesystem |
The on-disk format the kernel mounts ( |
Mount point |
mount, bind mount |
The path in the directory tree where a filesystem appears.
Listed by |
A typical encrypted-LVM laptop stack looks like this. The
filesystem and the underlying block device are mandatory; everything
between them is optional and composable. Drop LUKS for an
unencrypted host, drop LVM for a single-FS-per-partition layout,
slot in md RAID between LUKS and the partitions for redundancy.
flowchart TB
subgraph US["User space"]
APP["Application"]
end
subgraph FSL["Filesystem (mandatory)"]
MNT["Mount point<br/>/, /home, /var"]
FS["Filesystem<br/>ext4 / xfs / btrfs"]
end
subgraph VL["Volume layers (optional, stackable)"]
LV["Logical volume<br/>/dev/vg0/root"]
VG["Volume group<br/>vg0"]
PV["Physical volume<br/>/dev/mapper/cryptroot"]
LUKS["LUKS / dm-crypt"]
MD["MD RAID array<br/>/dev/md0"]
end
subgraph BD["Block device (mandatory)"]
PART["Partition<br/>/dev/nvme0n1p3"]
DISK["Physical disk<br/>/dev/nvme0n1"]
end
APP --> MNT --> FS --> LV --> VG --> PV --> LUKS --> MD --> PART --> DISK
classDef opt fill:#1f2933,stroke:#58a6ff,stroke-dasharray:5 5;
classDef req fill:#1f2933,stroke:#56d364,stroke-width:2px;
class LV,VG,PV,LUKS,MD opt
class APP,MNT,FS,PART,DISK req
Common compositions the operator meets in the wild.
Single disk, single FS.
/dev/sda1formattedext4, mounted at/. Most VMs and containers ship like this.Encrypted root. Partition → LUKS → LVM → ext4. The default for Debian and Ubuntu when the installer’s “encrypt the entire disk” box is checked.
RAID + LVM. Two disks →
md0→ LVM → XFS. The classic small-server layout for storage that survives a single-disk failure.Btrfs / ZFS standalone.
mkfs.btrfs(orzpool create) manages disks, RAID, snapshots, and subvolumes itself. No LVM, no mdadm.Bind mount. No new device, no new FS.
mount --bind src dstexposes one path under another. Common in containers and chroots.
The rest of this page walks the tools layer by layer. lsblk -f
is the standard “what’s actually here” command and labels every
layer of the stack in one tree.
Disk layers#
A write from an application crosses seven layers of kernel machinery before bits land on the platter. Each layer has its own caches, queues, and tooling; performance bugs almost always live in the one the operator wasn’t watching.
flowchart TB
APP["Application<br/><i>read() / write() / mmap()</i>"]
VFS["VFS<br/><i>generic file API; common inode / dentry cache</i>"]
FS["Filesystem driver<br/><i>ext4 / xfs / btrfs / nfs</i>"]
PC["Page cache<br/><i>RAM-backed read / write buffer</i>"]
BLK["Block layer<br/><i>bio, request queues, multi-queue (blk-mq)</i>"]
SCH["I/O scheduler<br/><i>mq-deadline / kyber / bfq / none</i>"]
DM["Device-mapper / md / LVM<br/><i>optional; LUKS, RAID, LVM, multipath</i>"]
DRV["Device driver<br/><i>nvme / scsi-mod / ahci / usb-storage / virtio-blk</i>"]
BUS["Host bus<br/><i>PCIe / SATA / SAS / USB / virtio</i>"]
HW["Storage media<br/><i>NVMe flash / SSD / spinning platter</i>"]
APP --> VFS --> FS
FS --> PC
PC --> BLK
BLK --> SCH --> DM --> DRV --> BUS --> HW
classDef us fill:#1f6feb22,stroke:#58a6ff;
classDef ks fill:#23863622,stroke:#56d364;
classDef hw fill:#8957e522,stroke:#a371f7;
class APP us
class VFS,FS,PC,BLK,SCH,DM,DRV ks
class BUS,HW hw
The same layers in tabular form, each with the tool the operator reaches for to inspect or tune it.
Layer |
Where it lives |
Inspection / tuning tool |
|---|---|---|
Application |
user space |
|
VFS |
kernel |
|
Filesystem driver |
kernel |
|
Page cache |
kernel RAM |
|
Block layer |
kernel |
|
I/O scheduler |
kernel |
|
Device-mapper / md |
kernel (optional) |
|
Device driver |
kernel module |
|
Host bus |
hardware |
|
Storage media |
hardware |
|
List and Identify#
Command |
Effect |
|---|---|
|
Tree of block devices, sizes, mount points |
|
Add filesystem type, label, UUID |
|
Custom columns |
|
UUIDs, labels, FS types per device |
|
Just one device |
|
Disks indexed by filesystem UUID |
|
Disks indexed by FS label |
|
Stable hardware IDs (preferred for fstab) |
|
GPT partition UUIDs |
|
USB tree (not just storage) |
|
USB tree with bandwidth and driver info |
|
Full udev attribute dump |
|
Detailed hardware report (when installed) |
|
SMART health and stats |
|
Identify ATA / SATA disk (model, firmware) |
Mount and Unmount#
Command |
Effect |
|---|---|
|
Show all current mounts (no args) |
|
Tree of mounts (cleaner than |
|
Resolve where a path is mounted |
|
Find the mount that owns a path |
|
Mount with type auto-detected |
|
Mount with explicit FS type |
|
Mount with options |
|
Remount in place with new options |
|
Mount an image file via a loop device |
|
Make SRC also visible at DST |
|
NFS mount |
|
CIFS / SMB mount |
|
Mount everything in |
|
Unmount |
|
Lazy unmount (when device is busy) |
|
Force (last resort, e.g. dead NFS) |
|
Flush kernel buffers to disk before unplug |
When a mount is “busy” and umount refuses, find the offending
process before reaching for -l / -f.
$ sudo lsof +f -- /mnt/data
$ sudo fuser -mv /mnt/data
$ sudo lsof | grep '(deleted)' | head
USB and Removable Media#
USB sticks and SD cards usually appear as /dev/sdX (or
/dev/mmcblk* for SD) and auto-mount under
/media/<user>/<label> on desktops via udisks2. Headless or
scripted work mounts manually under /mnt and runs sync
before pulling the device.
Command |
Effect |
|---|---|
|
Confirm the new device path |
|
Watch kernel messages on plug-in |
|
List drives udisks2 knows about |
|
Mount as the desktop would |
|
Unmount via udisks2 |
|
Spin down + safe-remove the drive |
|
Eject optical media |
|
Eject removable USB |
|
Flush, then safe-remove |
Burn an ISO to a USB stick.
Warning
These commands overwrite the entire device unconditionally.
Confirm the target with lsblk first; writing to the wrong
/dev/sdX will destroy the data on it. Always target the whole
disk (/dev/sdb), never a partition (/dev/sdb1).
$ lsblk -o NAME,SIZE,MODEL,TRAN,MOUNTPOINT
$ for p in /dev/sdb?*; do sudo umount "$p" 2>/dev/null; done
$ sudo dd if=distro.iso of=/dev/sdb \
bs=4M conv=fsync oflag=direct status=progress
$ sudo cp distro.iso /dev/sdb && sync
$ sudo sh -c 'cat distro.iso > /dev/sdb' && sync
$ pv distro.iso | sudo dd of=/dev/sdb bs=4M conv=fsync oflag=direct
$ pv distro.iso | sudo tee /dev/sdb >/dev/null && sync
$ sudo usbimager
$ sudo usbimager -i distro.iso -o /dev/sdb -v
$ sync
$ sudo udisksctl power-off -b /dev/sdb
$ sha256sum distro.iso
$ sudo dd if=/dev/sdb bs=4M count=$(stat -c%s distro.iso) iflag=count_bytes \
| sha256sum
Other common writers.
Tool |
Notes |
|---|---|
|
POSIX, ubiquitous, no progress without |
|
Raw byte copy; simple, no extra package |
|
Pipes a progress bar in front of any writer |
|
Lightweight cross-platform CLI + GUI |
|
Cross-platform GUI; verifies after write |
|
GNOME GUI; writes one ISO to many USBs in parallel |
|
Fedora-flavored GUI; can also fetch the ISO |
|
Older GUI; supports persistence |
|
Special bootloader; copy multiple ISOs onto one stick |
|
Debian/Ubuntu-focused safety wrapper around |
|
Specifically for Windows ISOs (NTFS layout) |
Notes worth keeping in mind.
bs=4Mchooses a 4 MiB block size (good throughput on most USB sticks);conv=fsyncflushes at the end;status=progressprints throughput whileddruns.Modern hybrid ISOs (Debian, Ubuntu, Arch, Kali, Fedora) are designed for raw write and will boot directly from the stick.
For Windows ISOs, use
woeusb. A rawddproduces a stick that BIOS / UEFI cannot boot from.For booting multiple ISOs from one stick, use
ventoy. It installs a small bootloader, then ISOs are plain files copied to the FAT / exFAT partition.
Persistent Mounts (/etc/fstab)#
Each line is six whitespace-separated fields
(device mountpoint type options dump pass). Prefer
UUID= or LABEL= over /dev/sdX so cabling changes don’t
break boot.
/etc/fstab is one mount per line, fields separated by tabs or spaces,
# starts a comment.
$ cat /etc/fstab
# <device> <mountpoint> <type> <options> <dump> <pass>
UUID=8e0f1c5a... / ext4 defaults,noatime 0 1
UUID=1234-ABCD /boot/efi vfat umask=0077,shortname=winnt 0 2
LABEL=HOME /home ext4 defaults,noatime 0 2
UUID=abcd1234-... /mnt/data ext4 defaults,noatime,nofail 0 2
UUID=11112222-... none swap sw 0 0
tmpfs /tmp tmpfs defaults,nosuid,nodev,size=2G 0 0
/dev/.../USB /mnt/usb auto noauto,user,exec 0 0
nas.lan:/exports/media /mnt/media nfs _netdev,rw,noatime 0 0
//fileserver/share /mnt/share cifs credentials=/etc/smb.cred,_netdev 0 0
Device#
What to mount. The operator picks one of several forms; UUID is the
safe default on bare metal because cabling and BIOS enumeration can
shuffle /dev/sdX between boots.
Form |
When to use it |
|---|---|
|
Preferred. Filesystem UUID from |
|
Filesystem label from |
|
GPT partition identity (not FS identity). Useful when the filesystem will be reformatted but the partition stays put. |
|
Stable hardware ID from |
|
Kernel-assigned path. Avoid for permanent mounts; order changes silently on hardware swaps. |
|
NFS export (e.g. |
|
CIFS / SMB share (note the two leading slashes). |
|
Pseudo-filesystem; no backing device. |
Mountpoint#
The directory where the filesystem becomes visible to userspace.
Must exist before
mount -aruns (mkdir -pit first).Convention.
/for root,/boot,/boot/efi,/home,/var,/srv,/opt,/tmp,/mnt/<name>for ad-hoc mounts,/media/<user>/<label>for desktop auto-mounts. See FHS.noneis the placeholder when the entry has no mountpoint semantics (swap files, bind mount sources in some forms).
Type#
The filesystem driver. Either spell out the type (ext4, xfs,
btrfs, vfat, exfat, f2fs, ntfs3, nfs,
nfs4, cifs, tmpfs, proc, sysfs, overlay,
squashfs) or use auto to have the kernel probe the
superblock. Specifying the type explicitly is faster and fails
loudly when the device is unexpected.
Options#
A comma-separated list of mount flags. Reading these correctly
matters because they decide what userspace can do on the mount.
defaults expands to rw,suid,dev,exec,auto,nouser,async.
Option |
Effect |
|---|---|
|
|
|
Read-only or read-write. |
|
Skip atime updates on every read. Standard performance win, safe on most workloads. |
|
Update atime only when older than mtime / ctime (the modern kernel default). |
|
Skip atime on directory reads only. |
|
Refuse to execute binaries from this mount. Common on
|
|
Ignore SUID / SGID bits on this mount. |
|
Ignore device-special files on this mount. |
|
Skip on |
|
Allow a regular user to mount / unmount the entry. |
|
Boot continues if the device is missing. Essential for removable / network mounts on headless hosts. |
|
Wait for the network before mounting. Required for NFS, CIFS, iSCSI-backed mounts. |
|
Mount lazily on first access (systemd). |
|
Wait for the named unit before mounting. |
|
Issue TRIM on every delete. Prefer |
|
Transparent compression algorithm. |
|
Which subvolume to mount as the root of this entry. |
|
Ownership and mode for filesystems without Unix permissions. |
|
File holding |
|
Upper bound on RAM consumed by the mount. |
Operator-relevant combinations.
defaults,noatime,nofailfor a data disk that might be missing.defaults,noatime,nosuid,nodev,noexecfor/tmp,/var,/home, removable media. Hardens against SUID-staged escalations and dropped-binary execution.ro,nosuid,nodev,noexecfor an audit-log volume.
Dump#
The legacy dump(8) backup flag.
0skip (almost always correct on modern systems;dumpis retired).1include in dump backups.
Leave at 0 unless the host actually runs dump.
Pass#
The fsck order at boot.
0skip the filesystem entirely (pseudo-filesystems, swap, network mounts).1reserved for the root filesystem; checked first.2non-root filesystems; checked in parallel after root.
Most operator-managed entries use 2 for ext / xfs data volumes
and 0 for everything that has no on-disk fsck path.
Common snippets.
Snippet |
Meaning |
|---|---|
|
Typical data mount |
|
Mount by FS label |
|
User-mountable, not on boot |
|
RAM-backed |
|
CIFS / SMB share (credentials file is in |
|
NFS export |
|
Enable a swap file |
|
Bind mount |
Partition and Format#
These commands change disk contents. Run them only against the device
you intend to overwrite. parted and fdisk write on
confirmation; mkfs formats unconditionally.
Command |
Effect |
|---|---|
|
List partition tables on all disks |
|
Interactive MBR / GPT partitioning |
|
Print partition table |
|
Create a fresh GPT label |
|
Single full-disk partition |
|
Scriptable GPT inspection |
|
GPT-only interactive |
|
Erase all FS / partition signatures |
|
Create ext4 with a label |
|
Reserve only 1% for root (raise free space on data disks) |
|
Create XFS |
|
Create Btrfs |
|
Btrfs across two disks, mirrored data |
|
F2FS (flash-friendly; SD cards, eMMC) |
|
FAT32 (USB / EFI) |
|
exFAT (cross-platform USB) |
|
Format and enable swap |
|
Set ext-family label |
|
Set XFS label |
|
Set FAT label |
Repair and Maintenance#
Command |
Effect |
|---|---|
|
Check / repair (run on unmounted FS) |
|
Force-check ext4 |
|
Repair XFS (unmounted) |
|
Check Btrfs (unmounted) |
|
Inspect / tune ext-family parameters |
|
Adjust the reserved-block percentage |
|
Relabel an ext volume |
|
Grow / shrink ext (after partition change) |
|
Grow XFS online (cannot shrink) |
|
Grow Btrfs online |
|
TRIM all SSD-backed mounts (run weekly) |
|
Weekly TRIM via systemd timer |
|
Run a short SMART self-test |
|
Read the SMART self-test log |
|
Non-destructive surface scan |
|
Wipe (destructive!) |
Capacity#
Block-device tools answer “what disks are here”. Capacity tools answer “where is the space going”. Both questions show up in the first hour of any storage incident.
Command |
Effect |
|---|---|
|
Free / used per mounted filesystem, with type |
|
Inode usage (the silent killer when many small files) |
|
Top-level usage under a path, sorted ascending |
|
Two levels deep |
|
Logical size (vs on-disk; handy with sparse files) |
|
Interactive disk-usage browser (install separately) |
|
Processes holding files on a busy mount |
|
Same question, simpler output |
|
Open-but-deleted files still consuming space |
When df says the disk is full but du cannot find the bytes,
something is holding a deleted file open. Restart or kill the
process; the space frees the moment the last reference closes.
LVM#
LVM (Logical Volume Manager) sits between the block layer and the filesystem. The operator gets a pool of storage (a VG built from one or more PVs) carved into resizable, named pieces (LVs). Filesystems sit on the LVs; growing or shrinking is online.
flowchart BT
subgraph BLOCK["Block devices (PVs)"]
direction LR
PV1["/dev/sdb<br/><i>pvcreate</i>"]
PV2["/dev/sdc<br/><i>pvcreate</i>"]
PV3["/dev/sdd<br/><i>pvcreate</i>"]
end
subgraph GROUP["Volume group (vgcreate)"]
VG[("vg0<br/><i>pool of extents</i>")]
end
subgraph LVS["Logical volumes (lvcreate)"]
direction LR
LV1["/dev/vg0/root<br/>50 GiB"]
LV2["/dev/vg0/home<br/>200 GiB"]
LV3["/dev/vg0/data<br/>1 TiB"]
end
subgraph FS["Filesystems"]
direction LR
F1["ext4 → /"]
F2["xfs → /home"]
F3["ext4 → /mnt/data"]
end
PV1 --> VG
PV2 --> VG
PV3 --> VG
VG --> LV1
VG --> LV2
VG --> LV3
LV1 --> F1
LV2 --> F2
LV3 --> F3
Command |
Effect |
|---|---|
|
One-line summary of PVs, VGs, LVs |
|
Verbose form |
|
Mark a block device as an LVM physical volume |
|
Pool one or more PVs into a volume group |
|
Add a PV to an existing VG |
|
Drop a PV from a VG (move data first with |
|
Carve a 100 GiB LV named |
|
Use all remaining free extents |
|
Grow the LV by 20 GiB; |
|
Shrink (must shrink the FS first; ext4 supports it, XFS does not) |
|
Rename an LV |
|
Delete an LV |
|
Migrate extents from one PV to another, online |
Snapshots. LVM snapshots are copy-on-write. Create one before a risky operation, mount it read-only, recover from it if the operation goes wrong.
$ sudo lvcreate -s -L 10G -n root_snap /dev/vg0/root
$ sudo mount -o ro /dev/vg0/root_snap /mnt/snap
$ sudo umount /mnt/snap
$ sudo lvremove /dev/vg0/root_snap
Thin provisioning. Allocate from a thin pool only when blocks
are written, so the sum of LV sizes can exceed the pool. The
container-storage backend (devicemapper, overlay2 on top of
thinpool) is built on this.
$ sudo lvcreate --thinpool tp0 -L 500G vg0
$ sudo lvcreate -V 200G -T vg0/tp0 -n vol1
$ sudo lvcreate -V 200G -T vg0/tp0 -n vol2
End-to-end create and grow.
$ sudo pvcreate /dev/sdb
$ sudo vgcreate vg0 /dev/sdb
$ sudo lvcreate -L 100G -n data vg0
$ sudo mkfs.ext4 /dev/vg0/data
$ sudo mount /dev/vg0/data /mnt/data
$ sudo vgextend vg0 /dev/sdc
$ sudo lvextend -L +50G -r /dev/vg0/data
RAID#
Software RAID (mdadm) combines block devices for redundancy or
striping. The kernel exposes the array as a single /dev/mdN; the
filesystem above sees one disk.
Command |
Effect |
|---|---|
|
Create a RAID-1 mirror across two disks |
|
RAID-5 across three disks |
|
Live array state (rebuild progress, faulty members) |
|
Verbose array status |
|
Read the array superblock from a member device |
|
Add a spare to the array |
|
Mark a member faulty (testing or replacement prep) |
|
Drop the member from the array |
|
Reshape the array (e.g. add a disk to a RAID-5) |
|
Stop the array (unmount first) |
|
Persist the array so it assembles on boot |
Rebuild progress lives in /proc/mdstat;
echo check > /sys/block/md0/md/sync_action triggers a periodic
scrub.
LUKS#
cryptsetup manages LUKS-encrypted block devices. The decrypted
view appears as /dev/mapper/<name>; the filesystem above is
unaware of the encryption.
Command |
Effect |
|---|---|
|
Initialize a LUKS volume (destructive) |
|
Unlock; map at |
|
Lock and remove the mapping |
|
Show keyslots, cipher, MK digest |
|
Add another passphrase or keyfile (up to 8 slots) |
|
Revoke one key |
|
Re-read the underlying device size after grow |
|
Cipher / hash speed for this CPU |
For full encryption coverage (per-archive, per-file, per-disk), see Encryption.
Snapshots#
Three sources of point-in-time copies on Linux. Each one freezes a different layer of the stack.
Source |
Notes |
|---|---|
LVM |
|
Btrfs |
|
ZFS |
|
For consistent snapshots while the filesystem is live, freeze writes first.
$ sudo fsfreeze --freeze /mnt/data
$ sudo lvcreate -s -L 5G -n data_snap /dev/vg0/data
$ sudo fsfreeze --unfreeze /mnt/data
Swap#
Swap is space the kernel uses when RAM is tight. It can be a partition, a separate file, or a zram device backed by RAM compression. The operator picks based on host profile (laptops favor swap files, dense servers often skip swap entirely).
Command |
Effect |
|---|---|
|
List active swap (file, partition, priority, used) |
|
RAM and swap totals at a glance |
|
Format a partition as swap |
|
Enable a swap area |
|
Disable a swap area |
|
Read or tune how aggressively the kernel swaps (0-200; default 60) |
Swap-file pattern, the modern default on systems that need swap at all.
$ sudo fallocate -l 4G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Encrypted swap is required for hibernation. Either put swap on a LUKS-backed partition, or use a randomly-keyed swap device (lost across reboots, no hibernation).
Loop devices and image files#
A loop device exposes a regular file as a block device. The operator uses this to mount disk images, build VM images, test filesystem layouts without touching real hardware, and assemble sparse storage that grows on demand.
Command |
Effect |
|---|---|
|
Attach the next free loop device, scan for partitions |
|
List all attached loop devices |
|
Detach |
|
Re-read partition table after image edit |
|
One-shot loop mount (no explicit losetup) |
|
Pre-allocate a 10 GiB sparse file |
|
Same idea, holes only (no allocation) |
|
Create a fully written 1 GiB image (slow, predictable) |
End-to-end build of a partitioned image.
$ fallocate -l 4G disk.img
$ sudo losetup -fP --show disk.img
$ sudo parted -s /dev/loop0 mklabel gpt mkpart primary ext4 1MiB 100%
$ sudo mkfs.ext4 /dev/loop0p1
$ sudo mount /dev/loop0p1 /mnt
$ sudo umount /mnt
$ sudo losetup -d /dev/loop0
Bind mounts#
A bind mount exposes a directory under a second path without copying data. The kernel routes I/O against either path to the same underlying inodes. Used to remap paths in chroots, containers, and service-isolation setups.
Command |
Effect |
|---|---|
|
Make |
|
Recursive bind (nested mounts come too) |
|
Remount the bind read-only |
|
Stop mount events propagating across namespaces |
|
Default; mount events propagate |
In /etc/fstab a bind looks like /src /dst none bind 0 0.
Quotas#
Per-user, per-group, and (on XFS / ext4 / Btrfs) per-project disk quotas. Cap how much a runaway tenant can consume on a shared filesystem.
Command |
Effect |
|---|---|
|
Enable user / group quotas at mount |
|
Build the quota database (offline, ext) |
|
Activate quotas |
|
Edit a user’s quota interactively |
|
Soft / hard block quota for one user |
|
Report quotas across all enabled filesystems |
|
XFS project quota (no daemon needed) |
Performance and I/O#
When a host feels slow and the question is “is the disk the
bottleneck”, these tools answer it. Keep iostat -xz 1 and
fio close to hand.
Tool |
Scope |
What it shows |
|---|---|---|
|
per-device |
Throughput, IOPS, await, util; refresh each second. |
|
per-process |
Top-style live view of disk read / write rates. |
|
per-process |
Read / write rates summarized per PID. |
|
host |
Combined disk + network throughput on one screen. |
|
block layer |
Latency histogram of block-layer I/O (bcc-tools). |
|
block layer |
Per-I/O latency trace, one line per request. |
|
block layer |
Full event-level trace of every I/O on a device. |
|
synthetic |
Configurable benchmark (rand / seq, read / write). |
Worked invocations.
$ iostat -xz 1
$ sudo iotop -oP
$ pidstat -d 1
$ dstat -dn 1
$ sudo biolatency-bpfcc
$ sudo biosnoop-bpfcc
$ sudo blktrace -d /dev/sdb -o trace && blkparse trace
$ fio --name=t --rw=randread --bs=4k --size=1G \
--runtime=30 --time_based --filename=/dev/sdb
I/O scheduler and queue tuning sit under /sys/block/<dev>/queue/.
Path |
Meaning |
|---|---|
|
Active scheduler (one of |
|
Maximum in-flight requests in the I/O queue |
|
Sequential read-ahead window (256 KiB default) |
|
1 for spinning disks, 0 for SSDs / NVMe |
|
CPU on which I/O completions are processed |
Common defaults. mq-deadline for SATA SSD, none for NVMe (the
device queue is large enough), bfq for laptops where interactive
responsiveness matters more than throughput.
Enterprise storage#
The block devices on a serious server are rarely a single disk attached over SATA. They reach the host through SAN or NAS protocols, multipath wiring, NVMe over Fabrics, or a hardware RAID controller. Each layer adds its own tooling.
Multipath I/O. When the same LUN is reachable over two HBAs,
device-mapper multipath presents a single /dev/mapper/mpath*
device; the FS uses one logical path while the kernel fails over
underneath.
Command |
Effect |
|---|---|
|
List active multipath devices and their paths |
|
Live path state from the daemon |
|
Flush all unused multipath maps |
|
Aliases, blacklist, path-checker, failover policy |
iSCSI (initiator). Attach a remote LUN as a local block device.
$ sudo iscsiadm -m discovery -t st -p portal.example.com
$ sudo iscsiadm -m node -T iqn.2025-01.example:lun1 -l
$ lsblk
$ sudo iscsiadm -m node -T iqn.2025-01.example:lun1 -u
NVMe. nvme-cli reads namespaces, SMART, and per-controller
state.
Command |
Effect |
|---|---|
|
Controllers and namespaces present |
|
Controller identify (model, serial, features) |
|
Wear, temperature, error counters |
|
Crypto-erase a namespace (verify before running) |
|
Firmware slots and active slot |
Hardware RAID. Vendor utilities read the controller’s view; the OS sees only the exposed virtual disks.
Tool |
Vendor / use |
|---|---|
|
LSI / Broadcom / Avago MegaRAID |
|
HPE Smart Array |
|
Dell PERC (rebadged MegaRAID) |
|
Adaptec / Microsemi |
|
Marvell |
Forensics and recovery#
When a disk is dying, deleted files matter, or the question is “what was on this drive before someone started writing to it”, forensic tooling separates the evidence from the changes.
Command |
Effect |
|---|---|
|
|
|
Plain- |
|
Hash a whole block device for chain-of-custody |
|
Partition-table recovery; rebuild lost partitions |
|
Carve files from raw blocks (filesystem-agnostic) |
|
Recover deleted files from ext3 / ext4 (best-effort) |
|
Sleuthkit, per-inode forensic inspection |
|
Web GUI for sleuthkit |
For acquisition, mount the source read-only or via a write-blocker; work from the image, never the original disk.
Advanced unlock#
LUKS by default takes a passphrase. For unattended boot, bind the unlock to a hardware or network secret so the host can come up without a human at the console.
Mechanism |
Notes |
|---|---|
TPM2 |
|
Network-bound (NBDE) |
Tang server + Clevis client; the disk unlocks only when the host can reach the Tang server. |
Smartcard / FIDO2 |
|
Common Tasks#
The recipes the operator runs on target.
Set up a fresh USB stick from scratch.
$ lsblk -f
$ sudo wipefs -a /dev/sdb
$ sudo parted -s /dev/sdb mklabel gpt
$ sudo parted -s /dev/sdb mkpart primary 1MiB 100%
$ sudo mkfs.exfat -n DATA /dev/sdb1
$ sudo mkdir -p /mnt/usb && sudo mount /dev/sdb1 /mnt/usb
Persist a new data disk in ``/etc/fstab`` so it mounts on boot.
$ uuid=$(sudo blkid -s UUID -o value /dev/sdb1)
$ echo "UUID=$uuid /mnt/data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
$ sudo mkdir -p /mnt/data
$ sudo mount -a
Free space when ``df`` and ``du`` disagree.
$ df -h
$ sudo du -sh /var/* | sort -h
$ sudo lsof | grep '(deleted)' | head
$ sudo systemctl restart suspect.service
Grow a logical volume and its filesystem in one step.
$ sudo vgextend vg0 /dev/sdc
$ sudo lvextend -L +50G -r /dev/vg0/data
Snapshot a live filesystem before a risky write.
$ sudo fsfreeze --freeze /mnt/data
$ sudo lvcreate -s -L 5G -n data_snap /dev/vg0/data
$ sudo fsfreeze --unfreeze /mnt/data
Image a failing disk with retries and a recovery map.
$ sudo ddrescue -d -r 3 /dev/sdb image.img map.log
$ sudo ddrescue -d -r 5 -R /dev/sdb image.img map.log
$ sha256sum image.img > image.sha256
Find what is using disk I/O right now.
$ iostat -xz 1
$ sudo iotop -oP
$ sudo biolatency-bpfcc
References#
man 8 lsblk,man 8 blkid,man 8 findmnt,man 8 udevadm,man 1 lsof,man 1 fuser(inspection).man 8 mount,man 8 umount,man 5 fstab,man 1 udisksctl,man 8 fsfreeze(mounting and bind mounts).man 8 parted,man 8 fdisk,man 8 gdisk,man 8 wipefs,man 8 mkfs,man 8 mkswap,man 8 swapon(partitioning and format).man 8 fsck,man 8 tune2fs,man 8 resize2fs,man 8 xfs_growfs,man 8 fstrim,man 8 badblocks(repair).man 8 lvm,man 8 pvcreate,man 8 vgcreate,man 8 lvcreate,man 8 lvextend,man 8 pvmove(LVM).man 8 mdadm,man 4 md(software RAID).man 8 cryptsetup,man 1 systemd-cryptenroll(LUKS and unlock).man 8 losetup,man 1 fallocate,man 1 truncate(loop and images).man 1 quota,man 8 quotacheck,man 8 quotaon,man 8 edquota,man 8 xfs_quota(quotas).man 1 iostat,man 1 iotop,man 1 pidstat,man 1 fio,man 8 blktrace,man 8 blkparse(performance).man 8 multipath,man 8 multipathd,man 5 multipath.conf,man 8 iscsiadm,man 1 nvme(enterprise storage).man 1 ddrescue,man 8 testdisk,man 1 photorec,man 1 sha256sum(forensics).man 8 smartctl,man 8 hdparm(drive health).Encryption for the encryption stack (LUKS, fscrypt, age / gpg).
FHS for where mountpoints conventionally live in the tree.
Permissions for
nosuid/noexec/nodevmount options.Filesystems for ext4 / XFS / Btrfs / ZFS / FAT comparison.
References for per-OS filesystem layouts.