From owner-freebsd-questions@FreeBSD.ORG Wed Mar 17 06:57:55 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3047916A4CF for ; Wed, 17 Mar 2004 06:57:55 -0800 (PST) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id C540A43D46 for ; Wed, 17 Mar 2004 06:57:54 -0800 (PST) (envelope-from jerrymc@clunix.cl.msu.edu) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.11.7p1+Sun/8.11.7) id i2HEviS10614; Wed, 17 Mar 2004 09:57:44 -0500 (EST) From: Jerry McAllister Message-Id: <200403171457.i2HEviS10614@clunix.cl.msu.edu> To: mirya@ukrpost.net (Kyryll A Mirnenko) Date: Wed, 17 Mar 2004 09:57:43 -0500 (EST) In-Reply-To: <200403130111.24664.mirya@ukrpost.net> from "Kyryll A Mirnenko" at Mar 16, 2004 02:31:11 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: Why does `df` lie about free space X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2004 14:57:55 -0000 > > That's an old problem, but yesterday I was working with 1.4G UFS2-slice > reported by `df` to have 400kb of free space. Alternative calculations (e.g. > writing a random file until kernel says no inode's free) give a result of > more that 100M (!) unused. Thats about 7% of the whole size! > That could a harmless bug, but some applications (PostgreSQL is!) uses > statfs to get free space info. Posetgres dies saying can't write his *.pid > cause FS is full (but it has 100M inodes free)... > So whats wrong with `df` (e.g. statfs/fstatfs)? Nothing. The thing that is wrong is that you do not understand disks. Disk space and inodes are almost completely unrelated concepts. If you look at the df man page, you might notice that if you do a df -i it will report the number of inodes as well as the amount of disk space. Those are under columns labeled iused, ifree and %iused. Disk space is just that, the amount of disk storage used and available but inodes are table entries. When you originally newfs a file system it creates a table with a certain number of entries. One of those entries is used for each file, directory and symlink that is created - no matter how big the file is. It is essentially a list of the files on the file system along with a bit of information on how to find the file and dates and such. So, if you create a lot of tiny files, you are likely to run out of inodes long before you run out of space on the disk. On the other hand, if you create even just one huge file, you could use just one inode and still use up all of the disk space. In addition to this, there are things such as reserves and different ways of measuring amounts of disk used that mean that different utilities report disk usage somewhat differently. All of this is well documented in the handbook, various published FreeBSD guides, plus there are FAQs on it so better start studying before you go to claiming that something is not working correctly. ////jerry