Re: df and du results on / strange

From: Bob Proulx (bob_at_proulx.com)
Date: 11/04/03

  • Next message: Roberto Sanchez: "Re: kdebase broken in sarge, what to do?"
    Date: Tue, 4 Nov 2003 11:16:04 -0700
    To: debian <debian-user@lists.debian.org>
    
    
    

    wsa wrote:
    > / is ext2, all others are ext3.
    > I get a almost 100% use of /
    > But with du i'm geting nowhere near 1.9GB total which is the size
    > of my / , in total i get to 568419 used on / if i take du's output as truth.
    > The real thruth is there's about 130MB free space on / , cause trying to
    > copy more that that to / results in 'no space left on device'.
    > What am i missing here?

    The 'minfree' value.

    When the filesystem is created 5%-10% of the total disk space will be
    reserved by the filesystem as 'minfree'. This is available only to
    root processes and not to non-root processes. The amount of minfree
    is dependent upon the defaults of the particular mkfs. You probably
    have 5% unless you changed it. Also some disk space will be used by
    Inodes in some filesystems. On others it is dynamic.

    Secondly the 'df' command is just returning data from the statfs(2)
    call.

                  struct statfs {
                     long f_type; /* type of filesystem (see below) */
                     long f_bsize; /* optimal transfer block size */
                     long f_blocks; /* total data blocks in file system */
                     long f_bfree; /* free blocks in fs */
                     long f_bavail; /* free blocks avail to non-superuser */
                     long f_files; /* total file nodes in file system */
                     long f_ffree; /* free file nodes in fs */
                     fsid_t f_fsid; /* file system id */
                     long f_namelen; /* maximum length of filenames */
                     long f_spare[6]; /* spare for later */
                  };

    So disk is usually total - minfree - inodes - free but the command
    does not compute it. The df command is just reporting what the
    filesystem has precomputed for those values.

    Also remember that when approaching a completely full disk the
    performance of the filesystem can degrade exponentially. It is then
    difficult for the filesystem to find free disk blocks and won't be
    able to automatically produce defragmented physical layout. A small
    percentage of minfree is required to ensure reasonable performance. I
    believe this plus ensuring root having a little extra when users
    filled the disk were the original reasons for minfree. It used to be
    10% but has been reduced to 5% in recent years because of the much
    larger disk capacity.

    > du -s /* | sort -nr | less :

    Also remember that du reports disk blocks used. A disk block will be
    different sizes on different filesystems. This is not the same as the
    disk space used. A three byte file takes up three bytes of used space
    but fits in one (likely 512 byte frag) disk block. Again, this is
    usually tuned by different filesystems and is one of the reasons
    different filesystems have different performance.

    Yes, it can be confusing.

    Bob

    
    

    -- 
    To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    


  • Next message: Roberto Sanchez: "Re: kdebase broken in sarge, what to do?"

    Relevant Pages

    • Re: df -h reporting weird numbers (FreeBSD 4.8)
      ... On my disk, this is the output for root: ... I see that the value of minfree is 8%: ... filesystem. ... To unsubscribe, ...
      (freebsd-questions)
    • Re: When File Systems Become Full
      ... > BTW, what's minfree? ... in my experience Solaris handles disk filling up ... to be creating or extending files in the affected filesystem. ...
      (comp.unix.solaris)
    • Weird harddisk behaviour
      ... A couple of weeks ago my 400Gb SATA disk crashed. ... Partition Table for /dev/sda ... # Type Sector Sector Offset Length Filesystem Type Flag ... Superblock backups stored on blocks: ...
      (Linux-Kernel)
    • Strange case of root filesystem corruption
      ... Yesterday GRUB would suddenly not display the boot menu anymore. ... Looking at filesystems on the disk with the free ufs2tools program, ... Subfolders of / on the same filesystem are affected as well. ... sectors/track: 63 ...
      (freebsd-questions)
    • Re: Making a bootable second hard disk (and larger filesystems)
      ... >filesystem on disk2 and it has to be bootable. ... >backup on second hard disk, ... under "root" and let both discs in the server? ... If you do only "dd" you may want to boot a "Knoppix" CD. ...
      (comp.unix.sco.misc)