Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Dec 2002 10:04:09 -0800
From:      "Paul A. Scott" <pscott@skycoast.us>
To:        <mike@ascendency.net>, "'Jens Rehsack'" <rehsack@liwing.de>, f-questions <freebsd-questions@freebsd.org>
Subject:   Re: [Fwd: Re: du -sh inconsistant with df -h]
Message-ID:  <BA235599.16B21%pscott@skycoast.us>
In-Reply-To: <001601c2a52a$58e88c80$c479f843@mike>

next in thread | previous in thread | raw e-mail | index | archive | help
> From: Mike Loiterman <mike@ascendency.net>
<snip>
>>>>> Where are the extra 1.6 megs at?
>>>> 
>>>> If a running process opens a file and then unlink(2)'s it, the
>>>> file will not
>>>> show up in the filesystem, and du will not reflect any space it
>>>> uses. However, df will.
>>>> 
>>>> Paul
>>> 
>>> 
>>> 
>>> So is there any way to reclaim that space aside from rebooting?
>> 
>> Kill that process.
>> 
> 
> How do I know which process is doing the right one?  Prseumably, the
> process itself has already been terminated, is this correct?

You probably don't want (or need) to kill the process. It is probably
working correctly. There are good reasons why a process will open a file and
then immediately unlink it while it's still open. If the file is unlinked,
then it can't be seen in the file system, so it's safer from prying eyes if
it contains confidential data. Also, if the process terminates unexpectedly
the file space is reclaimed automatically; no action required.

When an open file is unlinked, the used space is not reclaimed (and may even
grow larger if needed) until the file is closed or the process ends. This is
a feature of unix systems. I don't know of any other OS that does this, but
I've depended on this feature many times in the past when writing complex
shell scripts that needed a large scratchpad for sensitive data.

Read the man page on unlink(2) for an explanation.

Paul

-- 
Paul A. Scott
mailto:pscott@skycoast.us
http://skycoast.us/pscott/



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BA235599.16B21%pscott>