Block Devices and Partitions
Concept
Linux presents storage as block devices: whole disks, partitions, NVMe namespaces, virtio volumes, multipath maps, MD RAID, and LVM logical volumes. Everything that stores bytes — filesystems, swap, raw database devices — sits on this stack. You do not format, grow, or wipe anything until you can draw the stack for this host.
Why it matters
- Device names (
sda,nvme0n1,xvd) are not stable identities. The wrong name inwipefsorddis a career event. - Capacity tickets (“disk is 100%”, “resize did nothing”) are usually a missed layer: cloud volume grew, partition did not, or filesystem did not.
- Boot, initramfs, and fstab all key off UUID/PARTUUID/LABEL. Change the table without updating those and the next reboot is an emergency shell.
Mental Model
Identity: by-id / WWN / serial / cloud vol id (stable)
Name: /dev/sdX /dev/nvmeXnY /dev/vdX (not stable)
Stack (walk this every time):
Physical disk or cloud volume
→ partition table (GPT preferred; MBR legacy)
→ partition(s) and/or whole-disk PV
→ MD RAID / multipath (optional)
→ LVM PV → VG → LV (optional)
→ filesystem or raw device
→ mount point / swap
NVMe uses namespaces (nvme0n1) and partitions (nvme0n1p1). Virtio and Xen have their own names. Multipath hides several /dev/sd* paths behind one /dev/mapper/mpath*.
Always identify by UUID, PARTUUID, WWN, or /dev/disk/by-id/, never by sdX in fstab, scripts, or tickets.
Key Commands
# Live stack
lsblk -f
lsblk -o NAME,SIZE,TYPE,FSTYPE,UUID,MOUNTPOINT,MODEL,SERIAL,WWN,TRAN
lsblk -t # topology / alignment hints
lsblk -s /dev/mapper/vg-data
# Stable names
ls -l /dev/disk/by-id/ /dev/disk/by-uuid/ /dev/disk/by-partuuid/
blkid
# Partition tables
fdisk -l
sfdisk -d /dev/nvme0n1 # dump (scriptable)
parted /dev/nvme0n1 print
gdisk -l /dev/nvme0n1 # GPT specifics, protective MBR
# Kernel + hardware
cat /proc/partitions
dmesg -T | grep -iE 'sd[a-z]|nvme|I/O error|offline'
smartctl -a /dev/sdX
nvme smart-log /dev/nvme0
# Who holds the device
lsblk -o NAME,MOUNTPOINT
lsof +f -- /dev/sdX1
dmsetup ls --tree
# After attaching a new volume (guest SCSI rescan)
echo "- - -" > /sys/class/scsi_host/host0/scan
# NVMe usually appears without this; virtio depends on the hypervisorGrow sequence that people skip steps of:
- Grow the cloud volume / physical LUN
- Rescan so the guest sees the new size (
lsblk) - Grow the partition (
growpart/parted resizepart) if not whole-disk pvresizeif LVMlvextendresize2fsorxfs_growfs- Confirm with
lsblkanddf -h
Common Failure Modes & Symptoms
| Symptom | Likely cause | First checks |
|---|---|---|
| Device gone after reboot | Name shuffle, detach, failed path | lsblk, dmesg, by-id, cloud console |
| ”Device or resource busy” | Mounted, LVM/MD member, qemu/db holding it | lsblk, dmsetup ls, lsof |
| Size wrong after “resize” | Stopped at volume or partition layer | Compare cloud size → lsblk → df |
| Emergency mode on boot | fstab UUID no longer exists | blkid, /etc/fstab, initramfs |
| I/O errors in dmesg | Dying disk, cable, controller, flaky path | SMART, multipath -ll, dmesg |
| Duplicate UUID after clone | Disk/VM cloned bit-for-bit | blkid; change UUID before dual-mount |
| Partition overlap / leftover table | Old MBR + new GPT, or stale RAID superblock | wipefs -n /dev/X (report only) first |
| Multipath “missing disk” | Using a single path /dev/sdX instead of mapper | multipath -ll |
Investigation Tips
- Start every storage change with
lsblk -fand a screenshot / paste into the ticket. That is your rollback map. wipefs -nis the non-destructive way to see leftover signatures. Omit-nonly when you intend to erase them.- Alignment: modern tools default to 1 MiB. Weird start sectors show up as poor I/O on some arrays;
lsblk -tandpartedalignment-check help. - Cloud: map the console volume id to
by-id(nvme-Amazon_Elastic_Block_Store_vol..., Azure/GCP equivalents). Do not guesssdbvssdc. - After partition edits on the boot disk, rebuild initramfs and confirm GRUB/kernel root= still points at a UUID.
- Keep a one-page stack diagram for each critical host (disk → part → vg → lv → fs → mount). The 3 a.m. you will thank the afternoon you.
Related Notes
- SMART and Disk Health
- LUKS and Disk Encryption
- mdadm Operations
- Device Mapper Multipath
- lsblk
- LVM Deep Dive
- Filesystems and Mounts
- mount and findmnt
- df and du Deep Dive
- RAID Concepts
- O and Latency
- Troubleshooting Methodology
Personal Lessons Learned
I have watched a “quick wipe of the extra disk” hit
sdbafter a rescan reordered names.lsblk -o NAME,SIZE,SERIAL,MODELwould have shown it was the data disk. Serial first, command second.Cloud volume resized, ticket closed,
dfunchanged. The partition and XFS were never grown. Treat resize as a six-step checklist, not one console click.