<p>I recently ran out of disk space on a drive on a FreeBSD server.  I truncated the file that was causing problems but I'm not seeing the change reflected when running <code>df</code>.  When I run <code>du -d0</code> on the partition it shows the correct value.  Is there any way to force this information to be updated?  What is causing the output here to be different?</p>

[{'answer_id': 28752, 'author': 'mercutio', 'author_id': 1951, 'author_profile': 'https://Stackoverflow.com/users/1951', 'pm_score': -1, 'selected': False, 'text': '<p>Does df --sync work?</p>\n'}, {'answer_id': 28828, 'author': 'Stephen Darlington', 'author_id': 2998, 'author_profile': 'https://Stackoverflow.com/users/2998', 'pm_score': 3, 'selected': True, 'text': '<p>This probably centres on <em>how</em> you truncated the file. <em>du</em> and <em>df</em> report different things as <a href="http://www.unix.com/unix-dummies-questions-answers/29223-sco-unix-disk-space.html" rel="nofollow noreferrer">this post on unix.com explains</a>. Just because space is not used does not necessarily mean that it\'s free...</p>\n'}, {'answer_id': 447740, 'author': 'Dave C', 'author_id': 55504, 'author_profile': 'https://Stackoverflow.com/users/55504', 'pm_score': 2, 'selected': False, 'text': "<p>In BSD a directory entry is simply one of many references to the underlying file data (called an inode).  When a file is deleted with the rm(1) command only the reference count is decreased.  If the reference count is still positive, (e.g. the file has other directory entries due to symlinks) then the underlying file data is not removed.</p>\n\n<p>Newer BSD users often don't realize that a program that has a file open is also holding a reference.  The prevents the underlying file data from going away while the process is using it.  When the process closes the file if the reference count falls to zero the file space is marked as available.  This scheme is used to avoid the Microsoft Windows type issues where it won't let you delete a file because some unspecified program still has it open.</p>\n\n<p>An easy way to observe this is to do the following</p>\n\n<pre><code>cp /bin/cat /tmp/cat-test\n/tmp/cat-test &amp;\nrm /tmp/cat-test\n</code></pre>\n\n<p>Until the background process is terminated the file space used by /tmp/cat-test will remain allocated and unavailable as reported by df(1) but the du(1) command will not be able to account for it as it no longer has a filename.</p>\n\n<p>Note that if the system should crash without the process closing the file then the file data will still be present but unreferenced, an fsck(8) run will be needed to recover the filesystem space.</p>\n\n<p>Processes holding files open is one reason why the newsyslog(8) command sends signals to syslogd or other logging programs to inform them they should close and re-open their log files after it has rotated them.</p>\n\n<p>Softupdates can also effect filesystem freespace as the actual inode space recovery can be deferred; the sync(8) command can be used to encourage this to happen sooner.</p>\n"}]
['https://Stackoverflow.com/questions/28739', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/72/']