Assessing the Current State
Bash
# Block device list (including mount points)
lsblk
# Filesystem usage
df -h
# inode usage (file count limit issues)
df -i
# Usage by directory (one level)
du -sh /*
# Sort by size, largest first
du -sh /var/* | sort -rh | head -10Adding a Disk and Creating Partitions
Bash
# Identify the new disk (usually /dev/sdb or /dev/nvme1n1)
lsblk
fdisk -l /dev/sdb
# Create a partition (interactive)
fdisk /dev/sdb
# → n (new partition), p (primary), 1 (number), Enter, Enter (whole disk), w (write)
# GPT partition (2TB or larger)
parted /dev/sdb mklabel gpt
parted /dev/sdb mkpart primary ext4 0% 100%
# Format
mkfs.ext4 /dev/sdb1
# Mount
mkdir /data
mount /dev/sdb1 /data
# Auto-mount on boot (/etc/fstab)
echo "UUID=$(blkid -s UUID -o value /dev/sdb1) /data ext4 defaults 0 2" >> /etc/fstab
mount -a # Verify fstab took effectLVM — Extending Logical Volumes
Bash
# Check current LVM status
pvs # Physical volumes
vgs # Volume groups
lvs # Logical volumes
# Initialize the new disk as a physical volume
pvcreate /dev/sdb
# Add to an existing volume group
vgextend ubuntu-vg /dev/sdb
# Extend the logical volume (all free space)
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
# Grow the filesystem (ext4)
resize2fs /dev/ubuntu-vg/ubuntu-lv
# For XFS
xfs_growfs /Checking Disk Health
Bash
# SMART information
apt install smartmontools
smartctl -a /dev/sda
# Real-time I/O statistics
iostat -x 1 5
# Disk read/write speed test
dd if=/dev/zero of=/tmp/test bs=1M count=1024 oflag=directFreeing Space by Cleaning Logs
Bash
# Purge journald logs older than 2 weeks
journalctl --vacuum-time=2w
# Clean apt cache
apt autoremove && apt clean
# Remove unused Docker resources
docker system prune -a
# Delete old log files
find /var/log -name "*.gz" -mtime +30 -deleteEditorial note
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Questions & answers
Ask a question about this guide. We'll review and reply.