1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Disk Free Space Not Adding Up

Discussion in 'General' started by tad1214, Jul 12, 2010.

  1. tad1214

    tad1214 New Member

    Messages:
    20
    Likes Received:
    0
    Hello All

    I know that if you delete a file that is currently being written to it doesnt actually put the space back into the available space.

    Currently:
    Code:
    server1# df -h
    Filesystem     Size    Used   Avail Capacity  Mounted on
    /dev/da0s1a    496M    268M    188M    59%    /
    devfs          1.0K    1.0K      0B   100%    /dev
    /dev/da0s1e    496M    968K    455M     0%    /tmp
    /dev/da0s1f     57G     50G    1.9G    96%    /usr
    /dev/da0s1d    4.7G    2.3G    2.1G    52%    /var
    linprocfs      4.0K    4.0K      0B   100%    /usr/compat/linux/proc
    
    57 - 50 is not equal to 1.9G.

    I share this server with a few other people and I am guessing someone deleted a massive log file while the service was still writing to it.

    Is there any way to free this space up without rebooting my server?

    Thanks!
    -=Tom
     
  2. fronclynne

    fronclynne New Member

    Messages:
    1,297
    Likes Received:
    0
    1. df -h only give you a rounded approximation
    2. 8% is reserved, & does not show in the [red]Avail[/red] column

    You're probably better off not screwing with reserved blocks and space/time optimisations on your /usr/. If you wanted to screw around with that stuff, get another drive (or add another partition, if you have unallocated space on your drive) and mount it as /data/ or something and see what tunefs(8) can do (newfs(8) too, for that matter).

    Also: read this.
     
  3. tad1214

    tad1214 New Member

    Messages:
    20
    Likes Received:
    0
    Thanks for the help :) Getting more drives in the 1U isnt really an option and getting bigger SCSI drives is expensive. I may have to invest in another server I suppose.
     
  4. fronclynne

    fronclynne New Member

    Messages:
    1,297
    Likes Received:
    0
    Well, if you feel like poking around, /usr/ports/distfiles/ may have a bit of garbage, as with your (potentially defunct) working directories in ports (try # rm -r /usr/ports/*/*/work if you just don't care (or some find(1) goblox to check it out, if you must ([red]portsclean -CDL[/red], which is part of ports-mgmt/portupgrade also works quite well in this regard))). Look at /usr/obj/ as well (though it's normally only about 800M).

    Anyway, du(1) and find(1) are your friends. Learn them; use them.
     
  5. pbd

    pbd New Member

    Messages:
    191
    Likes Received:
    0
    You can use fstat to list biggest open files:

    Code:
    # echo -e "file size\tinode num\tmount\tcommand"; fstat | \
    awk '{ print $8, "\t", $6, "\t", $5, "\t", $2 }' | sort -nr | head
    file size       inode num       mount   command
    1862270976       1860727         /var    mysqld
    380840808        2802829         /var    lighttpd
    108508595        2802767         /var    httpd
    
    Then find to search for file with inode in that mount point. For example the first file in listing above:

    Code:
    find /var -inum 1860727
    If find doens't find any file with this inode, then it's probably the one deleted, that you are looking for and you can see that mysql is using it, so you can restart mysql to free the space.
     
  6. tad1214

    tad1214 New Member

    Messages:
    20
    Likes Received:
    0
    fstat was the command someone told me about before and I couldn't remember thanks!!!