Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

df

Show how much space is used and free on each mounted file system.

Niveau
RHCSA-examen
Groep
Schijven en bestandssystemen
Root nodig
Nee
Pakket
coreutils

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

df (disk free) lists the mounted file systems with their size, used space, free space, use percentage and mount point. It is the first command when somebody says "the disk is full".

With -h sizes are easy to read; with -T you also see the type (xfs, ext4, tmpfs, nfs). With -i it shows inodes: a disk can also be "full" when all inodes are used (millions of tiny files), even if there is free space.

Zo schrijf je het

df [OPTION]... [FILE]...

Opties 18

Meest gebruikt

-h, --human-readable
Sizes in powers of 1024, like 950M or 17G.
-T, --print-type
Show the file system type.
-i, --inodes
Show inode use instead of block use.
-H, --si
Sizes in powers of 1000 (like disk makers use).
-a, --all
Also show pseudo, duplicate and inaccessible file systems.
-l, --local
Only local file systems (no NFS or CIFS).
-t, --type=type
Only file systems of this type, like xfs.
-x, --exclude-type=type
Leave out this type, like tmpfs.
-k
Sizes in 1 KiB blocks.
-B, --block-size=size
Sizes in this unit, like M or G.
--output[=<fields>]
Choose the columns: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file, target.
--total
Add a line with the total.
-P, --portability
Use the POSIX output format (one line per file system, good for scripts).
--sync
Run sync before reading the numbers.
--no-sync
Do not run sync first (the default).
-v
Ignored.
--help
Show help.
--version
Show the version.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Show all file systems with readable sizes

    df -h

    Look at the Use% column. Above 90% needs action.

  2. 2Show the types too

    df -hT

    You see which ones are xfs, ext4, tmpfs or NFS.

  3. 3Which file system holds this folder?

    df -h /var/log

    Shows the file system that the folder is on.

  4. 4Check inodes when the disk is "full" but has space

    df -i /var

    100% IUse% means no new files can be made. Look for folders with millions of small files.

  5. 5Only real disks, no tmpfs

    df -h -x tmpfs -x devtmpfs

    A cleaner list for reports.

  6. 6Only XFS file systems

    df -hT -t xfs

    Useful when you check the volumes you created in the LVM chapter.

  7. 7Choose the columns for a report

    df -h --output=target,size,used,avail,pcent

    Easy to read and to paste in a ticket.

  8. 8Alert when a file system is above 85% (monitoring script)

    df -P | awk 'NR>1 && $5+0 > 85 {print "WARN", $6, $5}'

    -P keeps each file system on one line, so awk reads it safely.

  9. 9Check a new mount

    mount /dev/vdb1 /mnt/data && df -h /mnt/data

    Confirms the size and that the mount worked.

  10. 10Only local file systems

    df -hl

    Skips NFS shares that may hang when the server is down.

  11. 11Show the total of all file systems

    df -h --total | tail -1

    One number for the whole server.

Let op

  • df and du can disagree: a deleted file that a program still has open still uses space. Find it with lsof +L1.
  • XFS and ext4 keep some space reserved; "Avail" can be smaller than Size minus Used.
  • A hanging NFS server can make df hang. Use df -l or df -x nfs4.

Bestanden

/proc/self/mountinfo
The list of mounts that df reads.

Tips om te onthouden

  • df -hT = which disk, how full, what type. df -i = inodes.
  • df = per file system, du = per folder.