Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have file servers which are used to store files. Files might reside there for a week, or for a year. Unfortunately, when I remove files from the server, df command doesnt reflect the freed up space, so eventually, the server gets filled up (df shows 99%), and my script doesn't send any more files there, except there might be a few dozen GB of free space on there.

I got noatime flag on the mounted partitions if that makes any difference.

share|improve this question
Is this happening on a single partition or on all partitions? – Khaled Feb 8 '11 at 7:40
Well, its happening on my main data partition, which is the only one I care about, since I only write/remove files onto it. – k1lljoy Feb 8 '11 at 8:09
50 % of serverfaults's questions had been already asked and answered at least twice. – poige Feb 8 '11 at 8:27
Please enlighten me with the solution, or a link to one. – k1lljoy Feb 8 '11 at 8:51
What filesystem(s)? DF does a stat of the superblock, it may be that your filesystem is not updating the sb inode. Have you tried flushing cache? – beans Feb 8 '11 at 17:32
show 2 more comments

6 Answers

up vote 24 down vote accepted

Deleting the filename doesn't actually delete the file. Some other process is holding the file open, causing it to not be deleted; restart or kill that process to release the file.

share|improve this answer
Files that are removed were not accessed in over a month, and the only process that accesses them is nginx, so its doubtful. – k1lljoy Feb 8 '11 at 8:08
13  
+1. Also, "lsof +L1" will tell you which program is holding the files open. – pehrs Feb 8 '11 at 8:10
3  
as root run "lsof -n | grep file," you'd be surprised at how long files can stick around due to processes keeping them open for whatever reason. If all else fails, reboot, I feel bad suggesting it but it will definitely make sure nothing is holding on to the file. Per pehrs, lsof +L1 is probably the better way to go. – ScottZ Feb 8 '11 at 8:11
That returns a single file, which is being encoded with ffmpeg. – k1lljoy Feb 8 '11 at 8:16

One possibility is that the file(s) you deleted have more references in the filesystem. If you've created hardlinks, several filenames will point to the same data, and the data (the actual contents) won't be marked as free/usable until all references to it has been removed. Before you delete files, either stat them (Entry named Links) or do ls -l on them (should be the second column).

If it does turn out that the files are referenced elsewhere, I guess you'll have to ls -i the file(s) to find the inode-number, and then do a find with -inum <inode-number> to find the other references to that file (you probably also want to use -mount to stay within the same filesystem as well).

share|improve this answer

The other answers are correct: If you delete a file, and space does not get freed, it's usually either because the file is still kept open, or there are other hardlinks to it.

To help in troubleshooting, use a tool that tells you where the drive space is being spent: You can use du to get an overview of where space is going. Even better, use a graphical tool like xdiskusage (there are many like this) to hunt down the culprit. xdiskusage and friends let you drill down into the biggest space hogs to find where space is going.

That way, you'll quickly find files that still occupy space because of a second hardlink. It will also show space occupied by deleted, but open files (as (permission denied), I believe, since it cannot read the file name).

share|improve this answer

One more option: The disk might be full due to a process that is continuously creating data: logs, cores and the like. It is possible that space is actually being freed but is immediately filled up. I have actually seen such a case. df in this case simply doesn't give the hole picture. Use du to learn more.

share|improve this answer

I`m using EXT2, FSCK helped me in this situation. Try shudown -F now , after some restarts and fscks, I see half used space.

share|improve this answer
Dear Marcellus, your solution is encompassed by the accepted answer; and sometimes you don't want to do a reboot if you are not forced to... – Deer Hunter Jan 16 at 9:31

Since I know a ton of you are doing this for redhat in /var and gzipping files expecting the FS to shrink, but instead it grows, just make sure you service syslog restart. and lsof -v file would show you this anyhow.

share|improve this answer
This doesn't really add much; the accepted answer covered the logic behind that in 2001. When you have 50 rep, use comments if you want to add qualifiers to the existing answers. – Andrew B Mar 23 at 17:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.