Disk Usage Management (df, du, lsblk)

Ubuntu: Disk Usage Management (df, du, lsblk)

Disk management is essential for keeping your server healthy and preventing downtime. Ubuntu provides several commands to check and manage disk usage. This guide explains how to use df, du, and lsblk on Ubuntu servers.


Step 1: Check Overall Disk Usage

df -h

Displays disk usage in human-readable format (GB/MB).


Step 2: Check Disk Usage of a Specific Directory

du -sh /var/log

Shows the total size of the /var/log directory.

du -sh *

Displays the size of each file and folder in the current directory.


Step 3: List All Block Devices

lsblk

Displays information about all block devices (disks and partitions).


Step 4: Check Inodes Usage

df -i

Shows inode usage, useful for diagnosing “No space left on device” errors even when disk space is available.


Step 5: Find Large Files

find / -type f -size +500M

Lists files larger than 500MB.


Step 6: Clean Up Unused Files

sudo apt autoremove -y

sudo apt clean

Removes unused packages and cleans cached files.


Best Practices

  • Regularly check disk usage with df -h
  • Monitor log directories (/var/log) for growth
  • Use lsblk to verify disk partitions and mounts
  • Set up alerts for disk usage thresholds

Note: HostPalace servers provide scalable storage options, but monitoring disk usage ensures smooth performance and prevents outages.