Site Tools


wiki:debian-disk-and-filesystems

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, journaled - mkfs.xfs — high-performance - mkfs.btrfs — modern with snapshots - mkfs.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 — usually defaults, or comma-separated: noatime, nodiratime, noexec
  • dump — 0 to skip, 1 to include in dumps
  • fsck-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.

wiki/debian-disk-and-filesystems.md · Last modified: by 127.0.0.1