debian-disk-and-filesystems
Table of Contents
Debian disk and filesystems
Manage storage: partitions, formatting, mounting, and monitoring disk usage.
Listing disks and partitions
lsblk lsblk -f # show filesystems
Show device details:
fdisk -l parted -l
Partitioning
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
Formatting filesystems
Create ext4 filesystem (most common):
sudo mkfs.ext4 /dev/sda1
Other options:
mkfs.ext3: older, journaledmkfs.xfs: high-performancemkfs.btrfs: modern with snapshotsmkfs.vfat: FAT32 (USB drives)
Mounting
Mount filesystem (temporary):
sudo mount /dev/sda1 /mnt sudo umount /mnt
List mounted filesystems:
mount df -h
Persistent mounts
Edit /etc/fstab:
/dev/sda1 /home ext4 defaults 0 2
Format: device mount-point filesystem options dump fsck-order
options: usuallydefaults, or comma-separated:noatime,nodiratime,noexecdump: 0 to skip, 1 to include in dumpsfsck-order: 0 to skip, 1 for root, 2 for others
Test before applying:
sudo mount -a
Disk usage
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
Filesystem types
- ext4: reliable, default on Debian
- xfs: high-performance, used on servers
- btrfs: modern, supports snapshots and RAID
- vfat: FAT32, USB drives, Windows-compatible
- ntfs: Windows filesystems (limited support)
Checking filesystems
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.
Disk space issues
If disk is full:
sudo apt autoremove sudo apt clean sudo journalctl --vacuum=size=100M
Monitor space regularly to avoid emergency cleanup.
debian-disk-and-filesystems.md · Last modified: by 127.0.0.1
