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
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met sudo)
1Show all file systems with readable sizes
df -hLook at the Use% column. Above 90% needs action.
2Show the types too
df -hTYou see which ones are xfs, ext4, tmpfs or NFS.
3Which file system holds this folder?
df -h /var/logShows the file system that the folder is on.
4Check inodes when the disk is "full" but has space
df -i /var100% IUse% means no new files can be made. Look for folders with millions of small files.
5Only real disks, no tmpfs
df -h -x tmpfs -x devtmpfsA cleaner list for reports.
6Only XFS file systems
df -hT -t xfsUseful when you check the volumes you created in the LVM chapter.
7Choose the columns for a report
df -h --output=target,size,used,avail,pcentEasy to read and to paste in a ticket.
8Alert when a file system is above 85% (monitoring script)
df -P | awk 'NR>1 && $5+0 > 85 {print "WARN", $6, $5}'-Pkeeps each file system on one line, so awk reads it safely.9Check a new mount
mount /dev/vdb1 /mnt/data && df -h /mnt/dataConfirms the size and that the mount worked.
10Only local file systems
df -hlSkips NFS shares that may hang when the server is down.
11Show the total of all file systems
df -h --total | tail -1One number for the whole server.
Niets past bij dit filter.
Let op
dfandducan disagree: a deleted file that a program still has open still uses space. Find it withlsof +L1.- XFS and ext4 keep some space reserved; "Avail" can be smaller than Size minus Used.
- A hanging NFS server can make
dfhang. Usedf -lordf -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.