Chapter 11. Storage Devices, Partitions, and Mounts
Every disk, SSD, and USB stick a Debian system uses reaches the kernel as
a block device: a file under /dev that programs read and write in
fixed-size chunks. Between that raw device and the directory a user browses
sits a stack of administrator-built layers - a partition table, one or
more filesystems, a set of mount points, and the systemd units that mount
them at the right time. This chapter walks that stack from the bottom up:
identifying the devices a system actually has, partitioning a new disk,
creating filesystems on the right device, mounting them temporarily and
then persistently, deciding what should mount automatically on servers
and desktops, and maintaining the result - discard support, capacity and
inode monitoring, and the diagnosis of read-only remounts and failing I/O.
The administration of ext4, XFS, and Btrfs follows in
Chapter 12, and the layered stacks built from LVM,
RAID, and LUKS in Chapter 13; this chapter keeps
to the plain device-and-partition case everything else builds on.
The examples run on one Debian 13 system named storage (kernel
6.12.86+deb13-amd64, systemd 257, util-linux 2.41.5, parted 3.6-5,
gdisk 1.0.10, e2fsprogs 1.47.2, smartmontools 7.4, udisks2 2.10.1). Its
root filesystem lives on /dev/vda, a 100 GiB disk. Attached to it is
/dev/vdb, an empty 2 GiB disk that is this chapter's practice target:
every command that writes to /dev/vdb destroys what was on it, which is
exactly the property a practice disk needs. If you follow along, use any
second disk whose contents you do not need - a spare drive, a USB stick, or
a virtual disk attached to a disposable machine. The example disk is a
virtio device in a virtual machine; the commands are the same on physical
SATA, SAS, NVMe, and USB disks, and the few places where virtual hardware
behaves differently (SMART health data, most notably) are called out where
they occur.
Commands entered in john's ordinary shell begin with $ and commands
entered in a root shell begin with #; the prompt marker itself is not
typed. When a procedure says "in the root shell", enter sudo -i from
john's shell and leave it with exit; john's account and its sudo access
were established as part of installation (Chapter 2
created them, Chapter 5 covers the sudo
policy in depth). A single elevated command is written
$ sudo command. Practice images and scripts belong to john and live
under ~/debian-handbook/storage, created the first time they are needed.
The chapter assumes Chapter 3's shell operations
(including |, >, and >>), Chapter 6's
package management for the few tools not in a minimal install, and
Chapter 8's systemd unit model. The tools the
examples use beyond a base installation - the partitioners, the health and
mount services, the process finders, and the creation commands for XFS and
Btrfs whose versions Section 11.3.1 cites - are one ordinary install:
$ sudo apt install parted gdisk smartmontools udisks2 lsof psmisc dmsetup xfsprogs btrfs-progs
As always with Chapter 6's interactive
installs, answer the confirmation prompt when it appears. parted and
gdisk partition disks; smartmontools reads drive health; udisks2 is
the desktop mount service exercised in Section 11.4; lsof and psmisc
(for fuser) find the processes holding a busy filesystem; dmsetup
builds the synthetic failing device used in Section 11.5.3; and
xfsprogs/btrfs-progs provide mkfs.xfs and mkfs.btrfs. The ext4
tools (e2fsprogs) are part of every Debian base system. dosfstools and
exfatprogs, mentioned in the comparison but not used by the walkthrough,
install the same way when a FAT or exFAT volume is actually needed.