disk-usage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Disk Usage Skill

磁盘使用Skill

Analyzes disk space and filesystem usage on Linux systems.
分析Linux系统上的磁盘空间和文件系统使用情况。

Suggested Workflow

建议工作流程

  1. Run
    ./scripts/diskinfo.sh
    for a structured overview of mounts, block devices, and top directories.
  2. Check
    df -h
    output for any filesystem above 80% usage.
  3. Drill into high-usage mounts with
    du -h --max-depth=1 /mount
    to find large subdirectories.
  4. Locate specific large files with
    find /path -type f -size +100M
    .
  1. 运行
    ./scripts/diskinfo.sh
    以获取挂载点、块设备和顶层目录的结构化概览。
  2. 查看
    df -h
    的输出,检查是否有文件系统使用率超过80%。
  3. 使用
    du -h --max-depth=1 /mount
    深入分析高使用率挂载点,查找大子目录。
  4. 使用
    find /path -type f -size +100M
    定位特定的大文件。

Commands Reference

命令参考

Filesystem Overview

文件系统概览

  • df -h
    - Disk space usage for all mounted filesystems (human-readable)
  • df -i
    - Inode usage (number of files)
  • lsblk
    - Block device tree (disks, partitions)
  • mount
    - Currently mounted filesystems
  • df -h
    - 所有已挂载文件系统的磁盘空间使用情况(人类可读格式)
  • df -i
    - Inode使用情况(文件数量)
  • lsblk
    - 块设备树(磁盘、分区)
  • mount
    - 当前已挂载的文件系统

Directory Size Analysis

目录大小分析

  • du -sh /path
    - Total size of a directory
  • du -h --max-depth=1 /path
    - Size of immediate subdirectories
  • du -ah /path | sort -rh | head -20
    - Largest files/directories
  • du -sh /path
    - 目录的总大小
  • du -h --max-depth=1 /path
    - 直接子目录的大小
  • du -ah /path | sort -rh | head -20
    - 最大的文件/目录

Finding Large Files

查找大文件

  • find /path -type f -size +100M
    - Files larger than 100MB
  • find /path -type f -size +1G
    - Files larger than 1GB
  • ls -lhS /path | head -20
    - List files sorted by size (largest first)
  • find /path -type f -size +100M
    - 大于100MB的文件
  • find /path -type f -size +1G
    - 大于1GB的文件
  • ls -lhS /path | head -20
    - 按大小排序列出文件(从大到小)

Disk Information

磁盘信息

  • cat /proc/partitions
    - Partition table
  • cat /proc/mounts
    - Mount information
  • stat -f /path
    - Filesystem statistics
  • cat /proc/partitions
    - 分区表
  • cat /proc/mounts
    - 挂载信息
  • stat -f /path
    - 文件系统统计信息

Tips

提示

  • Always use
    -h
    for human-readable sizes
  • The
    du
    command can be slow on large directories; use
    --max-depth=1
    to limit recursion
  • Root filesystem (
    /
    ) usage above 90% may cause issues
  • 始终使用
    -h
    参数以获取人类可读的大小格式
  • du
    命令在大型目录上运行可能较慢;使用
    --max-depth=1
    限制递归深度
  • 根文件系统(
    /
    )使用率超过90%可能会导致问题