LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-03-2011, 12:50 AM   #1
bizna
LQ Newbie
 
Registered: Jul 2004
Location: Israel
Distribution: Mandrake, Debian
Posts: 3

Rep: Reputation: 0
Question [solved] df shows inconsistent numbers - a lot of 'lost' space - how to find sparse files


There is a very conspicuous inaccuracy in the output of df. I should mention, that it was noticed to to a sudden change in the amount of space that was left on the backup partition.

The df -h command produces the following output.
Code:
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdi1             936G  884G  4.3G 100% /backups
My suspicion was immediately directed towards sparse files. The script I found on the following link, found too many files, and no immediate culprit. A script for locating sparse files:
Code:
#!/bin/sh
# even in 30, it reduced too many results
typeset -i TOL=3 # plus or minus 3 blocks
while [[ ${#} -ge 1 ]]
  do
    typeset FNAME=${1}
    shift
    typeset -i SZ=$(ls -l "${FNAME}" | awk '{print $5}')
    typeset -i DUSZ=$(du -k "${FNAME}" | awk '{print $1}')
    typeset -i RSLT=$(echo "scale=0; h=0; a=(${SZ} / 1024) - ${DUSZ}; if (a < -${TOL}) h=1; if (a > ${TOL}) h=1; h" | bc)
    if [[ ${RSLT} -ne 0 ]]
      then
        echo "${FNAME}"
      fi
  done
exit 0
The question is: what can be the reason for this inaccuracy?

The server is a run-of-the-mill Centos, with a standard LAMP configuration.

For obvious reasons, the server can't be taken down for an fsck check. And anyway, the problem is not in the '/backups/' partition, as it is only storing data from other locations.

Any ideas?

Last edited by bizna; 02-06-2011 at 12:12 AM. Reason: matter is solved.
 
Old 02-03-2011, 07:20 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by bizna View Post
There is a very conspicuous inaccuracy in the output of df.
You've offered no evidence to support this claim.
Quote:
My suspicion was immediately directed towards sparse files.
Why ?. Sparse files have no adverse impacts on what "df" outputs - the "apparent size" is not included. At least on my test systems - I don't have CentOS handy at the moment, but I've been doing sparse testing for ages.
Quote:
And anyway, the problem is not in the '/backups/' partition, as it is only storing data from other locations.
Supposition by you - until you can fsck it you can't make that assertion.
 
Old 02-04-2011, 04:14 AM   #3
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Looks like the usual 5% reserved for the root account on /dev/sdi1 is making the difference. You can use e.g. tune2fs to adjust it.
 
Old 02-06-2011, 12:11 AM   #4
bizna
LQ Newbie
 
Registered: Jul 2004
Location: Israel
Distribution: Mandrake, Debian
Posts: 3

Original Poster
Rep: Reputation: 0
Post

Quote:
Originally Posted by Reuti View Post
Looks like the usual 5% reserved for the root account on /dev/sdi1 is making the difference. You can use e.g. tune2fs to adjust it.
Right you are!

The following command allowed to reclaim the 'lost' space:
tune2fs -m 0 /dev/sdi1

And regarding the sparse files, I've found out some very big differences between the du and the ls, when looking at the big MySQL ibd files. Sadly enough, the only safe way of getting rid of that empty space, is by export/import to a new DB.

Thanks for all the help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] find the total of numbers that are higher than x in a text file with numbers (using awk??) Mike_V Programming 12 11-24-2010 09:51 AM
How to find inverse of a sparse matrix? smp Linux - Newbie 17 06-25-2010 03:21 PM
reserving space on the disk for sparse files madhukirant Programming 1 08-17-2005 07:29 PM
can't find source files / line numbers with gdb dnijaguar Linux - Software 0 07-14-2003 01:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration