Manage storage: partitions, formatting, mounting, and monitoring disk usage.
lsblk lsblk -f # show filesystems
Show device details:
fdisk -l parted -l
Interactive partition editor:
sudo cfdisk /dev/sda
Or fdisk (older, text-based):
sudo fdisk /dev/sda
Or parted (supports GPT):
sudo parted /dev/sda
After partitioning, reread partition table:
sudo partprobe /dev/sda
Create ext4 filesystem (most common):
sudo mkfs.ext4 /dev/sda1
Other options:
- mkfs.ext3 — older, journaled
- mkfs.xfs — high-performance
- mkfs.btrfs — modern with snapshots
- mkfs.vfat — FAT32 (USB drives)
Mount filesystem (temporary):
sudo mount /dev/sda1 /mnt sudo umount /mnt
List mounted filesystems:
mount df -h
Edit /etc/fstab:
/dev/sda1 /home ext4 defaults 0 2
Format: device mount-point filesystem options dump fsck-order
options — usually defaults, or comma-separated: noatime, nodiratime, noexecdump — 0 to skip, 1 to include in dumpsfsck-order — 0 to skip, 1 for root, 2 for othersTest before applying:
sudo mount -a
Show usage per filesystem:
df -h
Show directory size:
du -sh /path/to/dir du -sh /path/to/dir/*
Find large files:
find / -type f -size +1G
Check for errors (unmounted only):
sudo fsck /dev/sda1 sudo e2fsck -n /dev/sda1 # read-only check
During boot, systemd runs fsck on damaged filesystems automatically.
If disk is full:
sudo apt autoremove sudo apt clean sudo journalctl --vacuum=size=100M
Monitor space regularly to avoid emergency cleanup.