SUSE Support

Here When You Need Us

Different free disk space reported by df and du commands

This document (7010921) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Desktop 11 Service Pack 1
SUSE Linux Enterprise Desktop 11 Service Pack 2
SUSE Linux Enterprise Server 10 Service Pack 4
SUSE Linux Enterprise Server 11 Service Pack 1
SUSE Linux Enterprise Server 11 Service Pack 2
SUSE Linux Enterprise Server for System z
SUSE Linux Enterprise Server for SAP Applications

Situation

The df (display free disk space) and du (display disk usage) utilities may report different free disk space.

Resolution

This behavior is related to deallocated inodes - a situation where files are deleted while they are still being open by a program or process.

Workaround:

Command lsof lists open files, so any deleted file still being open by a process or program can be found.

Additional Information

The following example was created on openSUSE 12.2 which uses tmpfs for /media and is different to SLE10 or SLE11, but the outcome is the same:

1. List free disk space using "df -h":

linux:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           20G  5,9G   14G  32% /
devtmpfs        2,0G   36K  2,0G   1% /dev
tmpfs           2,0G  768K  2,0G   1% /dev/shm
tmpfs           2,0G  628K  2,0G   1% /run
/dev/sda6        20G  5,9G   14G  32% /
tmpfs           2,0G     0  2,0G   0% /sys/fs/cgroup
tmpfs           2,0G  628K  2,0G   1% /var/lock
tmpfs           2,0G     0  2,0G   0% /media
tmpfs           2,0G  628K  2,0G   1% /var/run
/dev/sda7       274G   55G  218G  21% /home



2. Create a large file as root inside /media folder (showing 0% used space in df output):

linux:~ # dd if=/dev/zero of=/media/testfile bs=1024 count=500000
500000+0 records in
500000+0 records out
512000000 bytes (512 MB) copied, 0,351566 s, 1,5 GB/s


3. Print the output of du and df:

linux:~ # echo -e "\ndf output:\n" ; df -h;\
echo -e "\ndu output:\n" ; du -h --max-depth=1 /media

df output:

Filesystem      Size  Used Avail Use% Mounted on
rootfs           20G  5,9G   14G  32% /
devtmpfs        2,0G   44K  2,0G   1% /dev
tmpfs           2,0G  808K  2,0G   1% /dev/shm
tmpfs           2,0G  656K  2,0G   1% /run
/dev/sda6        20G  5,9G   14G  32% /
tmpfs           2,0G     0  2,0G   0% /sys/fs/cgroup
tmpfs           2,0G  656K  2,0G   1% /var/run
tmpfs           2,0G  656K  2,0G   1% /var/lock
tmpfs           2,0G  489M  1,5G  25% /media
/dev/sda7       274G   55G  218G  21% /home

du output:

489M    /media

The reported size is same for both commands.


4. Open the testfile in vi editor with:

linux:~ # vi /media/testfile


5. In other terminal session remove the file:

linux:~ # rm /media/testfile


6. Print the df and du output again:

linux:~ # echo -e "\ndf output:\n" ; df -h; \
echo -e "\ndu output:\n" ; du -h --max-depth=1 /media

df output:

Filesystem    Size  Used Avail Use% Mounted on
rootfs         20G  5,9G   14G  32% /
devtmpfs    2,0G   44K  2,0G   1% /dev
tmpfs        2,0G  808K  2,0G   1% /dev/shm
tmpfs        2,0G  656K  2,0G   1% /run
/dev/sda6     20G  5,9G   14G  32% /
tmpfs        2,0G     0  2,0G   0% /sys/fs/cgroup
tmpfs        2,0G  656K  2,0G   1% /var/run
tmpfs        2,0G  656K  2,0G   1% /var/lock
tmpfs        2,0G  489M  1,5G  25% /media
/dev/sda7    274G   55G  218G  21% /home

du output:

4,0K    /media


Because the file is still in use by vi editor df still reports 489M in use, while du lists no space used on /media.


7. This will list all large files on /media:

linux:~ # lsof /media | awk '{ if($7 > 1048576) print $7/1048576 "MB" " " $9 }'
0MB NAME
488.281MB /media/testfile

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7010921
  • Creation Date: 12-Oct-2012
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Desktop
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.