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
List block devices as a tree
lsblk

# Show disks, partitions, loop devices, and mountpoints.

Show filesystems with UUIDs
lsblk -f

# Display filesystem type, label, UUID, and mountpoint.

Select custom lsblk columns
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
blkid

# Read known filesystem, RAID, and partition metadata.

Show mounted filesystems
findmnt

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

Find mountpoints for a device
findmnt -S /dev/sda1

# Filter the mount table by source device.

Show filesystem free space
df -h

# Display used and available capacity in human-readable units.

Show inode usage
df -i

# Check inode exhaustion when space looks free but writes fail.

Summarize current directory usage
du -sh .

# Estimate disk usage for the current directory tree.

Find largest top-level directories
du -xh --max-depth=1 /var | sort -h

# Great first pass for finding where storage is going.

Show filesystem stats for a path
stat -f /var

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

Inspect a disk image or device signature
file -s /dev/sdb

# Read magic signatures from a block device or image.

## Partitions and Labels
List partition tables
sudo fdisk -l

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

Edit a disk with fdisk
sudo fdisk /dev/sdb

# Interactive MBR/GPT partitioning for a specific disk.

Print partition layout with parted
sudo parted /dev/sdb print

# Display partition table details using parted.

Create a GPT label
sudo parted /dev/sdb mklabel gpt

# Initialize a disk with a GPT partition table.

Create a new partition
sudo parted -a optimal /dev/sdb mkpart primary ext4 1MiB 100%

# Create a partition aligned for modern disks.

Ask kernel to reread partition table
sudo partprobe /dev/sdb

# Refresh partition table changes without rebooting.

Dump partition table to a file
sudo sfdisk -d /dev/sdb > sdb.partitions

# Useful for backups and repeatable partition layouts.

Restore a partition table dump
sudo sfdisk /dev/sdb < sdb.partitions

# Replay a previously exported partition layout.

List filesystem or RAID signatures
sudo wipefs /dev/sdb

# See what signatures exist before repurposing a disk.

Erase old signatures
sudo wipefs -a /dev/sdb

# Remove existing filesystem, RAID, or partition signatures.

Show PARTUUID and UUID
blkid -o export /dev/sdb1

# Good for preparing stable fstab entries.

Wait for udev after partition changes
sudo udevadm settle

# Wait until udev finishes processing newly created partitions.

## Format, Label, and Tune
Create an ext4 filesystem
sudo mkfs.ext4 /dev/sdb1

# Format a partition as ext4.

Create an XFS filesystem
sudo mkfs.xfs /dev/sdb1

# Format a partition as XFS.

Create a FAT32 filesystem
sudo mkfs.vfat -F 32 /dev/sdb1

# Useful for EFI partitions or removable media.

Create swap area
sudo mkswap /dev/sdb2

# Initialize a partition or file as swap.

Set an ext filesystem label
sudo e2label /dev/sdb1 data

# Assign a human-readable label to an ext filesystem.

Set an XFS label
sudo xfs_admin -L data /dev/sdb1

# Assign a label to an XFS filesystem.

Show ext filesystem metadata
sudo tune2fs -l /dev/sdb1

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

Change reserved blocks percentage
sudo tune2fs -m 1 /dev/sdb1

# Lower reserved space on large non-root data volumes.

Dump ext filesystem superblock info
sudo dumpe2fs -h /dev/sdb1

# Show ext superblock and journal settings.

Show XFS filesystem geometry
sudo xfs_info /mnt/data

# Display XFS geometry and feature flags.

Enable a swap device
sudo swapon /dev/sdb2

# Turn on swap after creating it.

List active swap
swapon --show

# Inspect active swap devices and priorities.

Recommended next

No recommendations yet.