Operating System - Linux
1748088 Members
4992 Online
108758 Solutions
New Discussion юеВ

Re: deleted file still occupying space

 
iinfi1
Super Advisor

deleted file still occupying space

I think this question would have appeared many times in several forums.
I read that rm'ing a file actually deletes only the name of the file if it is open and the file inode is still present.
it can be removed by killing processes which lsof lists with empty names.
we have 2 nodes of RAC n I use one ocfs moutpoint for export dumps. the export dumps are 4-5G big and sometimes i do a TAR.GZ of the exp files and remove the original ones to save space.
today i did the same and deleted 10 .EXP files immediately after tarring them. I found that the space around 25G occupied by the files did not get released.

user@dbs1:~> df -h | grep u10
/dev/sdi1 200G 164G 37G 82% /u10
user@dbs1:~> du -sh /u10/
113G /u10/

this is how my system shows as of now. I am lucky it didnt happen to a production mountpoint which is running out of space.
I would like to know how i should handle this in future.
>> If I leave it as is, will the new files automatically write to the disk without running out space.

lsof does not show anything for me. I mean there is no file which has empty names.

any inputs on how to deal with such situations and what I should do now to recover this space (apart from rebooting).
20 REPLIES 20
Patrick Wallek
Honored Contributor

Re: deleted file still occupying space

What lsof command did you use?

The best way to find deleted files is with 'lsof +L 1'

Try that and see what you find.
Patrick Wallek
Honored Contributor

Re: deleted file still occupying space

Here's an example of output from a quick test I did:

# lsof +L 1 | grep afile
more 19812 root 3r REG 8,2 110079 0 558341 /root/afile (deleted)


This shows that /root/afile has been deleted but is still open by the 'more' command from pid 19812.
Steven E. Protter
Exalted Contributor

Re: deleted file still occupying space

Shalom,

The deleted file will occupy space so long as a process maintains an open file handle on it.

Lets use /tmp as an example

fuser -cu /tmp
# displays process with open file handles on the file system

fuser -cuk /tmp

Kills them all. Very dangerous. I warned you.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
iinfi1
Super Advisor

Re: deleted file still occupying space

hi..thanks Steven,Patrik for your inputs.
the command i was trying all this while was
lsof /u10
shows no output

lsof +L 1
does not show the files which i deleted yesterday. how do i deal with this.

and further, if I now copy a 50G file into the partition /u10, will it run out of space at 37G or will it overwrite the open handles?
iinfi1
Super Advisor

Re: deleted file still occupying space

i am afraid i hit a roadblock here.
diff between df and dh is as below. I am losing over 50G

user1@dbs1:~> du -sh /u10/
114G /u10/
user1@dbs1:~> df -h | grep u10
/dev/sdi1 200G 166G 35G 83% /u10
taylan kurtkaya
Advisor

Re: deleted file still occupying space

hi iinfi,
run "lsof |grep deleted" command and then kill that processes
taylan.
iinfi1
Super Advisor

Re: deleted file still occupying space

this doesnt show the files which i had deleted.

the command lsof | grep deleted shows a whole bunch of files ... none actually show a size greater than zero.
my partition is a ocfs partition which is shared on two nodes
Dennis Handly
Acclaimed Contributor

Re: deleted file still occupying space

>this doesn't show the files which I had deleted.

How can you tell, wrong filesystem?

>none actually show a size greater than zero.

Why not clean them up too?
iinfi1
Super Advisor

Re: deleted file still occupying space

the lsof | grep deleted shows files in the /u01 partition. this is where oracle home is installed.
i deleted files. backup exp dumps from /u10 which is an ocfs partition.
current status
du -sh /u10/
128G /u10/
Filesystem Size Used Avail Use% Mounted on
/dev/sdi1 200G 180G 21G 90% /u10

52G loss.
there are about 110 entries when i run lsof | grep deleted. is it safe to kill those processes.