Mr Dk.'s BlogMr Dk.'s Blog
  • 🦆 About Me
  • ⛏️ Technology Stack
  • 🔗 Links
  • 🗒️ About Blog
  • Algorithm
  • C++
  • Compiler
  • Cryptography
  • DevOps
  • Docker
  • Git
  • Java
  • Linux
  • MS Office
  • MySQL
  • Network
  • Operating System
  • Performance
  • PostgreSQL
  • Productivity
  • Solidity
  • Vue.js
  • Web
  • Wireless
  • 🐧 How Linux Works (notes)
  • 🐧 Linux Kernel Comments (notes)
  • 🐧 Linux Kernel Development (notes)
  • 🐤 μc/OS-II Source Code (notes)
  • ☕ Understanding the JVM (notes)
  • ⛸️ Redis Implementation (notes)
  • 🗜️ Understanding Nginx (notes)
  • ⚙️ Netty in Action (notes)
  • ☁️ Spring Microservices (notes)
  • ⚒️ The Annotated STL Sources (notes)
  • ☕ Java Development Kit 8
GitHub
  • 🦆 About Me
  • ⛏️ Technology Stack
  • 🔗 Links
  • 🗒️ About Blog
  • Algorithm
  • C++
  • Compiler
  • Cryptography
  • DevOps
  • Docker
  • Git
  • Java
  • Linux
  • MS Office
  • MySQL
  • Network
  • Operating System
  • Performance
  • PostgreSQL
  • Productivity
  • Solidity
  • Vue.js
  • Web
  • Wireless
  • 🐧 How Linux Works (notes)
  • 🐧 Linux Kernel Comments (notes)
  • 🐧 Linux Kernel Development (notes)
  • 🐤 μc/OS-II Source Code (notes)
  • ☕ Understanding the JVM (notes)
  • ⛸️ Redis Implementation (notes)
  • 🗜️ Understanding Nginx (notes)
  • ⚙️ Netty in Action (notes)
  • ☁️ Spring Microservices (notes)
  • ⚒️ The Annotated STL Sources (notes)
  • ☕ Java Development Kit 8
GitHub
  • 📝 Notes
    • Algorithm
      • Algorithm - Bloom Filter
      • Algorithm - Disjoint Set
      • Algorithm - Fast Power
      • Algorithm - KMP
      • Algorithm - Monotonic Stack
      • Algorithm - RB-Tree
      • Algorithm - Regular Expression
      • Algorithm - Sliding Window
      • Online Judge - I/O
    • C++
      • C++ - Const
      • C++ File I/O
      • C++ - Object Layout
      • C++ - Operator Overload
      • C++ - Polymorphism
      • C++ STL algorithm
      • C++ STL map
      • C++ STL multimap
      • C++ STL priority_queue
      • C++ STL set
      • C++ STL string
      • C++ STL unordered_map
      • C++ STL vector
      • C++ - Smart Pointer
      • C++ - Template & Genericity
    • Compiler
      • ANTLR - Basic
      • Compiler - LLVM Architecture
      • Compiler - Multi-version GCC
    • Cryptography
      • Cryptography - Certbot
      • Cryptography - Digital Signature & PKCS #7
      • Cryptography - GPG
      • Cryptography - JWT
      • Cryptography - Keystore & Certificates
      • Cryptography - OAuth 2.0
      • Cryptography - Java 实现对称与非对称加密算法
      • Cryptography - TLS
    • DevOps
      • DevOps - Travis CI
    • Docker
      • Docker - Image & Storage Management
      • Docker - Image
      • Docker - Libcontainer
      • Docker - Multi-Arch Image
      • Docker - Multi-Stage Build
      • Docker - Network
      • Docker - Orchestration & Deployment
      • Docker - Overview
      • Docker - Service Building
      • Docker - Volume & Network Usage
      • Docker - Volume
      • Linux - Control Group
      • Linux - Namespace
    • Git
      • Git - Branch & Merge
      • Git - Cached
      • Git - Cherry Pick
      • Git - Commit
      • Git - Patch
      • Git - Proxy
      • Git - Rebase
      • Git - Reset
      • Git - Stash
      • Git - Theme for Git-Bash
    • Java
      • JVM - Synchronized
      • JVM - Volatile
      • Java - Annotation 注解
      • Java - BIO & NIO
      • Java - Class Path
      • Java - Condition and LockSupport
      • Java - Current Timestamp
      • Java - Deep Copy
      • Java - 运行环境配置
      • Java - Equals
      • Java - Exporting JAR
      • Java - Javadoc
      • Java - Lock
      • Java - Maven 项目构建工具
      • Java - References
      • Java - Reflection Mechanism
      • Java - String Split
      • Java - Thread Pool
      • Java - Thread
      • Tomcat - Class Loader
      • Tomcat - Container
    • Linux
      • addr2line
      • cut
      • df
      • du
      • fallocate
      • find
      • fio
      • grep
      • groupadd
      • gzip
      • head / tail
      • hexdump
      • iostat
      • iotop
      • kill
      • ldd
      • lsof
      • ltrace / strace
      • mpstat
      • netstat
      • nm
      • pidstat
      • pmap
      • readlink
      • readlink
      • rpm2cpio / rpm2archive
      • sort
      • tee
      • uniq
      • useradd
      • usermod
      • watch
      • wc
      • which
      • xargs
    • MS Office
      • MS Office - Add-in Dev
      • MS Office - Application
    • MySQL
      • InnoDB - Architecture
      • InnoDB - Backup
      • InnoDB - Checkpoint
      • InnoDB - Critical Features
      • InnoDB - Files
      • InnoDB - Index
      • InnoDB - Insert Buffer
      • InnoDB - Lock
      • InnoDB - Partition Table
      • InnoDB - Table Storage
      • MySQL - Server Configuration
      • MySQL - Storage Engine
    • Network
      • Network - ARP
      • Network - FTP
      • Network - GitHub Accelerating
      • HTTP - Message Format
      • HTTP - POST 提交表单的两种方式
      • Network - Proxy Server
      • Network - SCP
      • Network - SSH
      • Network - TCP Congestion Control
      • Network - TCP Connection Management
      • Network - TCP Flow Control
      • Network - TCP Retransmission
      • Network - Traceroute
      • Network - V2Ray
      • Network - WebSocket
      • Network - Windows 10 Mail APP
      • Network - frp
    • Operating System
      • Linux - Kernel Compilation
      • Linux - Multi-OS
      • Linux - Mutex & Condition
      • Linux - Operations
      • Linux: Package Manager
      • Linux - Process Manipulation
      • Linux - User ID
      • Linux - Execve
      • OS - Compile and Link
      • OS - Dynamic Linking
      • OS - ELF
      • Linux - Image
      • OS - Loading
      • OS - Shared Library Organization
      • OS - Static Linking
      • Syzkaller - Architecture
      • Syzkaller - Description Syntax
      • Syzkaller - Usage
      • Ubuntu - Desktop Recover (Python)
      • WSL: CentOS 8
    • Performance
      • Linux Performance - Perf Event
      • Linux Performance - Perf Record
      • Linux Performance - Perf Report
      • Linux Performance - Flame Graphs
      • Linux Performance - Off CPU Analyze
    • PostgreSQL
      • PostgreSQL - ANALYZE
      • PostgreSQL - Atomics
      • PostgreSQL - CREATE INDEX CONCURRENTLY
      • PostgreSQL - COPY FROM
      • PostgreSQL - COPY TO
      • PostgreSQL - Executor: Append
      • PostgreSQL - Executor: Group
      • PostgreSQL - Executor: Limit
      • PostgreSQL - Executor: Material
      • PostgreSQL - Executor: Nest Loop Join
      • PostgreSQL - Executor: Result
      • PostgreSQL - Executor: Sequential Scan
      • PostgreSQL - Executor: Sort
      • PostgreSQL - Executor: Unique
      • PostgreSQL - FDW Asynchronous Execution
      • PostgreSQL - GUC
      • PostgreSQL - Locking
      • PostgreSQL - LWLock
      • PostgreSQL - Multi Insert
      • PostgreSQL - Plan Hint GUC
      • PostgreSQL - Process Activity
      • PostgreSQL - Query Execution
      • PostgreSQL - Spinlock
      • PostgreSQL - Storage Management
      • PostgreSQL - VFD
      • PostgreSQL - WAL Insert
      • PostgreSQL - WAL Prefetch
    • Productivity
      • LaTeX
      • Venn Diagram
      • VuePress
    • Solidity
      • Solidity - ABI Specification
      • Solidity - Contracts
      • Solidity - Expressions and Control Structures
      • Solidity - Layout and Structure
      • Solidity - Remix IDE
      • Solidity - Slither
      • Solidity - Types
      • Solidity - Units and Globally Available Variables
    • Vue.js
      • Vue.js - Environment Variable
    • Web
      • Web - CORS
      • Web - OpenAPI Specification
    • Wireless
      • Wireless - WEP Cracking by Aircrack-ng
      • Wireless - WPS Cracking by Reaver
      • Wireless - wifiphisher

df

Created by : Mr Dk.

2022 / 12 / 26 0:20

Hangzhou, Zhejiang, China


Background

df 用于查看文件系统使用量信息。

Usage

$ df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all             include pseudo, duplicate, inaccessible file systems
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -h, --human-readable  print sizes in powers of 1024 (e.g., 1023M)
  -H, --si              print sizes in powers of 1000 (e.g., 1.1G)
  -i, --inodes          list inode information instead of block usage
  -k                    like --block-size=1K
  -l, --local           limit listing to local file systems
      --no-sync         do not invoke sync before getting usage info (default)
      --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                               or print all fields if FIELD_LIST is omitted.
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
      --total           elide all entries insignificant to available space,
                          and produce a grand total
  -t, --type=TYPE       limit listing to file systems of type TYPE
  -T, --print-type      print file system type
  -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  -v                    (ignored)
      --help     display this help and exit
      --version  output version information and exit

Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).

FIELD_LIST is a comma-separated list of columns to be included.  Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation at: <https://www.gnu.org/software/coreutils/df>
or available locally via: info '(coreutils) df invocation'

文件系统类型

使用 -T 参数打印文件系统的类型:

$ df -T
Filesystem     Type     1K-blocks    Used Available Use% Mounted on
udev           devtmpfs    966120       0    966120   0% /dev
tmpfs          tmpfs       203016    1016    202000   1% /run
/dev/vda2      ext4      41222348 9665792  29783868  25% /
tmpfs          tmpfs      1015068      24   1015044   1% /dev/shm
tmpfs          tmpfs         5120       0      5120   0% /run/lock
tmpfs          tmpfs      1015068       0   1015068   0% /sys/fs/cgroup
/dev/loop3     squashfs     64768   64768         0 100% /snap/core20/1695
/dev/loop4     squashfs    119552  119552         0 100% /snap/core/14399
/dev/loop0     squashfs     45696   45696         0 100% /snap/certbot/2582
/dev/loop1     squashfs     64768   64768         0 100% /snap/core20/1738
/dev/loop2     squashfs     45824   45824         0 100% /snap/certbot/2618
tmpfs          tmpfs       203012       0    203012   0% /run/user/0

打印所有文件系统

使用 -a 参数打印所有的文件系统,包括伪文件系统、不可访问的文件系统:

$ df -a -T
Filesystem     Type        1K-blocks    Used Available Use% Mounted on
sysfs          sysfs               0       0         0    - /sys
proc           proc                0       0         0    - /proc
udev           devtmpfs       966120       0    966120   0% /dev
devpts         devpts              0       0         0    - /dev/pts
tmpfs          tmpfs          203016    1016    202000   1% /run
/dev/vda2      ext4         41222348 9665864  29783796  25% /
securityfs     securityfs          0       0         0    - /sys/kernel/security
tmpfs          tmpfs         1015068      24   1015044   1% /dev/shm
tmpfs          tmpfs            5120       0      5120   0% /run/lock
tmpfs          tmpfs         1015068       0   1015068   0% /sys/fs/cgroup
cgroup2        cgroup2             0       0         0    - /sys/fs/cgroup/unified
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/systemd
pstore         pstore              0       0         0    - /sys/fs/pstore
none           bpf                 0       0         0    - /sys/fs/bpf
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/net_cls,net_prio
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/pids
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/perf_event
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/cpu,cpuacct
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/blkio
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/freezer
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/rdma
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/cpuset
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/hugetlb
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/memory
cgroup         cgroup              0       0         0    - /sys/fs/cgroup/devices
systemd-1      -                   -       -         -    - /proc/sys/fs/binfmt_misc
hugetlbfs      hugetlbfs           0       0         0    - /dev/hugepages
mqueue         mqueue              0       0         0    - /dev/mqueue
debugfs        debugfs             0       0         0    - /sys/kernel/debug
tracefs        tracefs             0       0         0    - /sys/kernel/tracing
sunrpc         rpc_pipefs          0       0         0    - /run/rpc_pipefs
configfs       configfs            0       0         0    - /sys/kernel/config
fusectl        fusectl             0       0         0    - /sys/fs/fuse/connections
tracefs        tracefs             0       0         0    - /sys/kernel/debug/tracing
binfmt_misc    binfmt_misc         0       0         0    - /proc/sys/fs/binfmt_misc
/dev/loop3     squashfs        64768   64768         0 100% /snap/core20/1695
/dev/loop4     squashfs       119552  119552         0 100% /snap/core/14399
/dev/loop0     squashfs        45696   45696         0 100% /snap/certbot/2582
/dev/loop1     squashfs        64768   64768         0 100% /snap/core20/1738
/dev/loop2     squashfs        45824   45824         0 100% /snap/certbot/2618
tmpfs          tmpfs          203012       0    203012   0% /run/user/0

打印使用量

以人类可读的格式打印:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            944M     0  944M   0% /dev
tmpfs           199M 1016K  198M   1% /run
/dev/vda2        40G  9.3G   29G  25% /
tmpfs           992M   24K  992M   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           992M     0  992M   0% /sys/fs/cgroup
/dev/loop3       64M   64M     0 100% /snap/core20/1695
/dev/loop4      117M  117M     0 100% /snap/core/14399
/dev/loop0       45M   45M     0 100% /snap/certbot/2582
/dev/loop1       64M   64M     0 100% /snap/core20/1738
/dev/loop2       45M   45M     0 100% /snap/certbot/2618
tmpfs           199M     0  199M   0% /run/user/0

以指定单位打印使用量:-B + 单位:

$ df -Bk
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             966120K       0K   966120K   0% /dev
tmpfs            203016K    1016K   202000K   1% /run
/dev/vda2      41222348K 9665988K 29783672K  25% /
tmpfs           1015068K      24K  1015044K   1% /dev/shm
tmpfs              5120K       0K     5120K   0% /run/lock
tmpfs           1015068K       0K  1015068K   0% /sys/fs/cgroup
/dev/loop3        64768K   64768K        0K 100% /snap/core20/1695
/dev/loop4       119552K  119552K        0K 100% /snap/core/14399
/dev/loop0        45696K   45696K        0K 100% /snap/certbot/2582
/dev/loop1        64768K   64768K        0K 100% /snap/core20/1738
/dev/loop2        45824K   45824K        0K 100% /snap/certbot/2618
tmpfs            203012K       0K   203012K   0% /run/user/0

$ df -Bm
Filesystem     1M-blocks  Used Available Use% Mounted on
udev                944M    0M      944M   0% /dev
tmpfs               199M    1M      198M   1% /run
/dev/vda2         40257M 9440M    29086M  25% /
tmpfs               992M    1M      992M   1% /dev/shm
tmpfs                 5M    0M        5M   0% /run/lock
tmpfs               992M    0M      992M   0% /sys/fs/cgroup
/dev/loop3           64M   64M        0M 100% /snap/core20/1695
/dev/loop4          117M  117M        0M 100% /snap/core/14399
/dev/loop0           45M   45M        0M 100% /snap/certbot/2582
/dev/loop1           64M   64M        0M 100% /snap/core20/1738
/dev/loop2           45M   45M        0M 100% /snap/certbot/2618
tmpfs               199M    0M      199M   0% /run/user/0

$ df -Bg
Filesystem     1G-blocks  Used Available Use% Mounted on
udev                  1G    0G        1G   0% /dev
tmpfs                 1G    1G        1G   1% /run
/dev/vda2            40G   10G       29G  25% /
tmpfs                 1G    1G        1G   1% /dev/shm
tmpfs                 1G    0G        1G   0% /run/lock
tmpfs                 1G    0G        1G   0% /sys/fs/cgroup
/dev/loop3            1G    1G        0G 100% /snap/core20/1695
/dev/loop4            1G    1G        0G 100% /snap/core/14399
/dev/loop0            1G    1G        0G 100% /snap/certbot/2582
/dev/loop1            1G    1G        0G 100% /snap/core20/1738
/dev/loop2            1G    1G        0G 100% /snap/certbot/2618
tmpfs                 1G    0G        1G   0% /run/user/0

查看 inode

使用 -i 参数查看 inode 使用量:

$ df -i
Filesystem      Inodes  IUsed   IFree IUse% Mounted on
udev            241530    420  241110    1% /dev
tmpfs           253767    657  253110    1% /run
/dev/vda2      2600960 113254 2487706    5% /
tmpfs           253767      7  253760    1% /dev/shm
tmpfs           253767      4  253763    1% /run/lock
tmpfs           253767     18  253749    1% /sys/fs/cgroup
/dev/loop3       11897  11897       0  100% /snap/core20/1695
/dev/loop4       12857  12857       0  100% /snap/core/14399
/dev/loop0        7452   7452       0  100% /snap/certbot/2582
/dev/loop1       11897  11897       0  100% /snap/core20/1738
/dev/loop2        7457   7457       0  100% /snap/certbot/2618
tmpfs           253767     22  253745    1% /run/user/0

References

12 Useful “df” Commands to Check Disk Space in Linux

Check your disk space use with the Linux df command

linux - df (1)

Edit this page on GitHub
Prev
cut
Next
du