LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-20-2007, 09:16 PM   #1
zok
Member
 
Registered: Sep 2006
Posts: 42

Rep: Reputation: 15
du vs df -- Huge difference; Disk Space Vanishing


A couple weird things are going. First, if I do a df -h, my system shows that 19G are being used on our /var parition, with 0 free space:

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 1012M 394M 567M 42% /
/dev/sda2 99M 47M 48M 50% /boot
/dev/sda8 9.9G 1.5G 7.9G 16% /home
none 1004M 0 1004M 0% /dev/shm
/dev/sda9 347G 93G 236G 29% /srv
/dev/sda11 2.0G 81M 1.8G 5% /tmp
/dev/sda10 4.0G 1.3G 2.6G 33% /usr
/dev/sda6 4.0G 2.1G 1.8G 55% /usr/local
/dev/sda5 20G 19G 0 100% /var

However, if I do a du -sh /var it reports that only 4.6G are being used:

# du -sh /var
4.6G /var

Furthermore, free space is somehow disappearing. If I delete say a 1G file, I can watch the newly freed space rapidly dwindle away by repeatedly doing a df -h. But du -sh /var still shows only 4.6G are being used. And I can't find any files with a larger file size in /var. Really weird. Any ideas?
 
Old 03-20-2007, 09:38 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
df and du measure two different things....

du reports the space used by files and folders--even this is more than the file size. A few quick experiments on my system show that 4K is a minimum file size in terms of disk space.

df reports the space used by the file system. This includes the overhead for journals and inode tables and such.
 
Old 03-20-2007, 11:24 PM   #3
zok
Member
 
Registered: Sep 2006
Posts: 42

Original Poster
Rep: Reputation: 15
Thanks, a simple reboot set everything straight.
 
Old 09-04-2012, 12:08 PM   #4
shdighan
LQ Newbie
 
Registered: Sep 2012
Posts: 1

Rep: Reputation: Disabled
Open files deleted

Use lsof to identify deleted files that are still open:

# lsof | grep deleted

The disk space the deleted file occupies will not be freed until the process with it open is terminated. In my case, a nohup'd tcpdump process was writing output to a deleted file in /tmp . After killing the process, the filesystem cleaned up the deleted file inodes within a minute or two. Afterward, du and df user space were nearly identical. A restart effectively does the same steps, but is not required.

Last edited by shdighan; 09-04-2012 at 12:10 PM.
 
Old 09-04-2012, 01:14 PM   #5
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,230

Rep: Reputation: 1071Reputation: 1071Reputation: 1071Reputation: 1071Reputation: 1071Reputation: 1071Reputation: 1071Reputation: 1071
Furthermore, note that df works by examining directory entries, which generally are updated only when a file is closed.
 
Old 09-04-2012, 02:13 PM   #6
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,597

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Also note that free space + used space will not be equal to total space when looking at df on most ext filesystems. Some (default is 5% for ext3) of the sectors are reserved for root, and don't appear as "available" in df.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cedega "Disk space required for the installation exceeds available disk space" Solved Spewdemon LinuxQuestions.org Member Success Stories 1 10-18-2007 06:19 PM
compact disk difference panhaiy1375 Programming 1 12-16-2005 03:18 AM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 03:58 PM
Large tar file taking huge disk space in ext3 file system pcwulf Linux - General 2 10-20-2003 07:45 AM
Disk space wastage 73 GB Hard disk rajgopalhg Linux - Hardware 2 10-18-2002 03:41 PM


All times are GMT -5. The time now is 02:11 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration