Problems deleting a large directory
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > Problems deleting a large directory




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Problems deleting a large directory  
Carla Tironi Farinati


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-09-06 07:56 AM

hi group!,

I'm trying to delete a very large directory full of small files (not
more than 20k each). The directory weights around 40GB. I'm running
Centos4.

Now when I try "rm -rf mydir", the system hangs and do nothing.

No change is displayed when I look for the free space.

I also tried to do a "rm *" inside the directory to delete to see if
the system displayed the question "remove the regular file XXX?", but
the console again hangs there as nothing.

Any other deletion of small directories or files works OK in the sys.

Any ideas?.

best,
Carla Tironi Farinati






[ Post a follow-up to this message ]



    Re: Problems deleting a large directory  
Alexey G. Khramkov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-09-06 11:02 PM

"Carla Tironi Farinati" <carlatf@gmail.com> writes:

> Now when I try "rm -rf mydir", the system hangs and do nothing.
>
> No change is displayed when I look for the free space.
>
> I also tried to do a "rm *" inside the directory to delete to see if
> the system displayed the question "remove the regular file XXX?", but
> the console again hangs there as nothing.

In both cases those commands generate full listing (the same long time).

>
> Any other deletion of small directories or files works OK in the sys.
>
> Any ideas?.

I don't sure it helps (i have no experience in the same environment).
Try a*, b* instead of *. Increase the statis part (2, 3, n letters)
if it will hang again.

Hint: use separate partition for that stuff:

# umount /monster
# newfs /dev/new_monster
# mount /dev/new_monster /monster

HTH,
--
status = rule("RFC1855"); /* avoid flame wars */





[ Post a follow-up to this message ]



    Re: Problems deleting a large directory  
Doug Freyburger


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-09-06 11:02 PM

Carla Tironi Farinati wrote:
>
> I'm trying to delete a very large directory full of small files (not
> more than 20k each). The directory weights around 40GB. I'm running
> Centos4.
>
> Now when I try "rm -rf mydir", the system hangs and do nothing.
> No change is displayed when I look for the free space.
>
> I also tried to do a "rm *" inside the directory to delete to see ...

With thousands of files the "rm *" will overflow the shell command
line buffer and fail.

With thousands of files "rm -rf mydir" probably needs to run a lot
longer to work.

Brute force method - This will take much longer but will run well:

find mydir \( \! -type d \) -print | xargs rm -f
find mydir -depth -print | xargs -1 rm -rf
rm -rf mydir

Since the first one will locate all non-directories and delete them
using a legal command line length, it will run for a very long time.
The second will run much faster.  The third will run as fast as you
can hit the return.

Here's a bizzare case.  I include it just in case the tree is so
deep that find runs out of virtual memory remembering how deep
it is:

Once I had a use try to install Clearcase on a workstation they
had the root password.  (This is also a lesson why users should
never get root).  They typed wrong and somehow convinced it
to try installing recursively.  It made a chain of about 5-6 levels
of empty directory, cd'd to the bottom and then looped to create
the chain all over again.  It started running and since the disk
access light was one the users went home and let it run.  About
200 MB later the process finally ran out of virtual memory and failed.
By that time it created a single chain of directories so deep no
shell could cd that deep.

Clearly if I wrote a loop of moving the dir one level down up one
to flatten it the script would have run for a week.  It had millions of
inodes in the chain .. to . each link.  But if I wrote a loop to "cd *"
that would fail as well.

The good part was that -

while true ; do
cd *
done

ran for several minutes then failed.  But when i tried to type "pwd"
it took minutes to start printing its name.  Great -

cd ..
mv * /mountpt/lost+found
rm -rf /mountpt/lost+found/*
cd /mountput/lost+found
cd *

lather rinse repeat.  Each attempt removed as many as their
names would fit in the shell's virtual memory and also moved the
rest up to an easily accessible location.  However many dirs
the original chain was deep, that's how many times I had to
run that sequence.  Prine pump by mooving to lost+found,
dive as deep as possible, move up one so it fits in VM, move
up to lost+found, attempt deletion, the "short"er chain suceeds.






[ Post a follow-up to this message ]



    Re: Problems deleting a large directory  
base60


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-10-06 04:01 AM

Carla Tironi Farinati wrote:
> hi group!,
>
> I'm trying to delete a very large directory full of small files (not
> more than 20k each). The directory weights around 40GB. I'm running
> Centos4.
>
> Now when I try "rm -rf mydir", the system hangs and do nothing.
>
> No change is displayed when I look for the free space.
>
> I also tried to do a "rm *" inside the directory to delete to see if
> the system displayed the question "remove the regular file XXX?", but
> the console again hangs there as nothing.
>
> Any other deletion of small directories or files works OK in the sys.
>
> Any ideas?.

If you want to watch them:

cd mydir
find . -type f -ls -exec rm {} \;


>
> best,
> Carla Tironi Farinati
>





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:37 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register