From owner-freebsd-doc Wed Nov 7 8:20:19 2001 Delivered-To: freebsd-doc@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 4892837B418 for ; Wed, 7 Nov 2001 08:20:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id fA7GK2O26503; Wed, 7 Nov 2001 08:20:02 -0800 (PST) (envelope-from gnats) Date: Wed, 7 Nov 2001 08:20:02 -0800 (PST) Message-Id: <200111071620.fA7GK2O26503@freefall.freebsd.org> To: freebsd-doc@freebsd.org Cc: From: Michael Lucas Subject: Re: docs/31821: new FAQ: du/df Reply-To: Michael Lucas Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR docs/31821; it has been noted by GNATS. From: Michael Lucas To: Dima Dorfman Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: docs/31821: new FAQ: du/df Date: Wed, 7 Nov 2001 11:10:34 -0500 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Nov 07, 2001 at 03:06:27PM +0000, Dima Dorfman wrote: > This is backwards. 'du' typically reports less space is in use, not > df (if you wrote this looking at the recent thread on -stable, note > that the originator misnamed the output; what he claimed was from du > was from df, and vice versa). Aha! That confused me, but I'm not going to argue with actual output. You've gone to a lot of trouble to prove me wrong, but I'm a tech writer. I assume that I will be proven wrong. :) Here's another patch, addressing your points. ==ml -- Michael Lucas mwlucas@blackhelicopters.org http://www.blackhelicopters.org/~mwlucas/ Big Scary Daemons: http://www.oreillynet.com/pub/q/Big_Scary_Daemons --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=du-vs-df *** en_US.ISO8859-1/books/faq/book.sgml-dist Mon Nov 5 10:49:36 2001 --- en_US.ISO8859-1/books/faq/book.sgml Wed Nov 7 11:09:10 2001 *************** *** 5869,5874 **** --- 5869,5929 ---- + + The du and df + commands show different amounts of disk space available. + What's going on? + + + + You need to understand what du and + df really do. du + goes through the directory tree, measures how large each + file is, and presents the totals. df + just asks the filesystem how much space it has left. They + seem to be the same thing, but a file without a directory + entry will affect df but not + du. + + When a program is using a file, and you delete the + file, the file isn't really removed from the filesystem + until the program stops using it. The file is immediately + deleted from the directory listing, however. You can see + this easily enough with a program such as + more. Assume you have a file large + enough that its presence affects the output of + du and df. (Since + disks can be so large today, this might be a + very large file!) If you delete this + file while using more on it, + more doesn't immediately choke and + complain that it cannot view the file. The entry is + simply removed from the directory so no other program or + user can access it. du shows that it + is gone -- it has walked the directory tree and the file + isn't listed. df shows that it is + still there, as the filesystem knows that + more is still using that space. Once + you end the more session, + du and df will + agree. + + Note that softupdates can delay the freeing of disk + space; you might need to wait up to 30 seconds for the + change to be visible! + + This situation is common on web servers. Many people + set up a FreeBSD web server and forget to rotate the log + files. The access log fills up /var. + The new administrator deletes the file, but the system + still complains that the partition is full. Stopping and + restarting the web server program would free the file, + allowing the system to release the disk space. To prevent + this from happening, set up &man.newsyslog.8;. + + + + How can I add more swap space? --3V7upXqbjpZ4EhLz-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message