Linux Disk Storage Cheat Sheet

Disk inventory, partitions, formatting, and capacity analysis for Linux systems.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Inventory and Capacity

Inspect block devices, filesystems, and space usage.

List block devices as a tree

Show disks, partitions, loop devices, and mountpoints.

bashANYlsblkinventoryblock-devices
bash
lsblk

Show disks, partitions, loop devices, and mountpoints.

Show filesystems with UUIDs

Display filesystem type, label, UUID, and mountpoint.

bashANYlsblkfilesystemuuid
bash
lsblk -f

Display filesystem type, label, UUID, and mountpoint.

Select custom lsblk columns

Useful when you want clean inventory output for documentation or scripts.

bashANYlsblkcolumnsinventory
bash
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINTS,UUID,MODEL

Useful when you want clean inventory output for documentation or scripts.

Probe block devices for signatures

Read known filesystem, RAID, and partition metadata.

bashANYblkiduuidfilesystem
bash
blkid

Read known filesystem, RAID, and partition metadata.

Show mounted filesystems

Display the live mount tree with source, target, and options.

bashANYfindmntmountinventory
bash
findmnt

Display the live mount tree with source, target, and options.

Find mountpoints for a device

Filter the mount table by source device.

bashANYfindmntmountdevice
bash
findmnt -S /dev/sda1

Filter the mount table by source device.

Show filesystem free space

Display used and available capacity in human-readable units.

bashANYdfspacecapacity
bash
df -h

Display used and available capacity in human-readable units.

Show inode usage

Check inode exhaustion when space looks free but writes fail.

bashANYdfinodescapacity
bash
df -i

Check inode exhaustion when space looks free but writes fail.

Summarize current directory usage

Estimate disk usage for the current directory tree.

bashANYduspacedirectory
bash
du -sh .

Estimate disk usage for the current directory tree.

Find largest top-level directories

Great first pass for finding where storage is going.

bashANYdusortdisk-usage
bash
du -xh --max-depth=1 /var | sort -h

Great first pass for finding where storage is going.

Show filesystem stats for a path

Inspect block size, available blocks, and filesystem ID for a mounted path.

bashANYstatfilesysteminspect
bash
stat -f /var

Inspect block size, available blocks, and filesystem ID for a mounted path.

Inspect a disk image or device signature

Read magic signatures from a block device or image.

bashANYfiledevicesignature
bash
file -s /dev/sdb

Read magic signatures from a block device or image.

Partitions and Labels

Create, inspect, and label partitions.

List partition tables

Show disks, sector sizes, partition tables, and partitions.

bashANYfdiskpartitioninventory
bash
sudo fdisk -l

Show disks, sector sizes, partition tables, and partitions.

Edit a disk with fdisk

Interactive MBR/GPT partitioning for a specific disk.

bashANYfdiskpartitioninteractive
bash
sudo fdisk /dev/sdb

Interactive MBR/GPT partitioning for a specific disk.

Print partition layout with parted

Display partition table details using parted.

bashANYpartedpartitioninventory
bash
sudo parted /dev/sdb print

Display partition table details using parted.

Create a GPT label

Initialize a disk with a GPT partition table.

bashANYpartedgptpartition
bash
sudo parted /dev/sdb mklabel gpt

Initialize a disk with a GPT partition table.

Create a new partition

Create a partition aligned for modern disks.

bashANYpartedmkpartpartition
bash
sudo parted -a optimal /dev/sdb mkpart primary ext4 1MiB 100%

Create a partition aligned for modern disks.

Ask kernel to reread partition table

Refresh partition table changes without rebooting.

bashANYpartprobepartitionkernel
bash
sudo partprobe /dev/sdb

Refresh partition table changes without rebooting.

Dump partition table to a file

Useful for backups and repeatable partition layouts.

bashANYsfdiskbackuppartition
bash
sudo sfdisk -d /dev/sdb > sdb.partitions

Useful for backups and repeatable partition layouts.

Restore a partition table dump

Replay a previously exported partition layout.

bashANYsfdiskrestorepartition
bash
sudo sfdisk /dev/sdb < sdb.partitions

Replay a previously exported partition layout.

List filesystem or RAID signatures

See what signatures exist before repurposing a disk.

bashANYwipefssignaturedisk
bash
sudo wipefs /dev/sdb

See what signatures exist before repurposing a disk.

Erase old signatures

Remove existing filesystem, RAID, or partition signatures.

bashANYwipefserasesignature
bash
sudo wipefs -a /dev/sdb

Remove existing filesystem, RAID, or partition signatures.

Show PARTUUID and UUID

Good for preparing stable fstab entries.

bashANYblkidpartuuiduuid
bash
blkid -o export /dev/sdb1

Good for preparing stable fstab entries.

Wait for udev after partition changes

Wait until udev finishes processing newly created partitions.

bashANYudevadmudevpartition
bash
sudo udevadm settle

Wait until udev finishes processing newly created partitions.

Format, Label, and Tune

Create filesystems and inspect or tune metadata.

Create an ext4 filesystem

Format a partition as ext4.

bashANYmkfsext4filesystem
bash
sudo mkfs.ext4 /dev/sdb1

Format a partition as ext4.

Create an XFS filesystem

Format a partition as XFS.

bashANYmkfsxfsfilesystem
bash
sudo mkfs.xfs /dev/sdb1

Format a partition as XFS.

Create a FAT32 filesystem

Useful for EFI partitions or removable media.

bashANYmkfsvfatfilesystem
bash
sudo mkfs.vfat -F 32 /dev/sdb1

Useful for EFI partitions or removable media.

Create swap area

Initialize a partition or file as swap.

bashANYmkswapswapfilesystem
bash
sudo mkswap /dev/sdb2

Initialize a partition or file as swap.

Set an ext filesystem label

Assign a human-readable label to an ext filesystem.

bashANYe2labellabelext4
bash
sudo e2label /dev/sdb1 data

Assign a human-readable label to an ext filesystem.

Set an XFS label

Assign a label to an XFS filesystem.

bashANYxfs_adminlabelxfs
bash
sudo xfs_admin -L data /dev/sdb1

Assign a label to an XFS filesystem.

Show ext filesystem metadata

Inspect features, UUID, mount count, and reserved blocks.

bashANYtune2fsext4metadata
bash
sudo tune2fs -l /dev/sdb1

Inspect features, UUID, mount count, and reserved blocks.

Change reserved blocks percentage

Lower reserved space on large non-root data volumes.

bashANYtune2fsreserved-blocksext4
bash
sudo tune2fs -m 1 /dev/sdb1

Lower reserved space on large non-root data volumes.

Dump ext filesystem superblock info

Show ext superblock and journal settings.

bashANYdumpe2fssuperblockext4
bash
sudo dumpe2fs -h /dev/sdb1

Show ext superblock and journal settings.

Show XFS filesystem geometry

Display XFS geometry and feature flags.

bashANYxfs_infoxfsgeometry
bash
sudo xfs_info /mnt/data

Display XFS geometry and feature flags.

Enable a swap device

Turn on swap after creating it.

bashANYswaponswap
bash
sudo swapon /dev/sdb2

Turn on swap after creating it.

List active swap

Inspect active swap devices and priorities.

bashANYswaponswapinventory
bash
swapon --show

Inspect active swap devices and priorities.

Recommended next

No recommendations yet.