LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-18-2005, 08:51 AM   #1
davesbedroom
LQ Newbie
 
Registered: Jan 2005
Posts: 27

Rep: Reputation: 15
Big Problem with overfilled directory


Problem, I have a directory with 188,692 equally sized files in it, taking up 9GB of space on an ext3 file system.

When will this crash? How would you go about moving files out of this directory and into others safely?

I try to look into the directory from samba and the client machine gets 100 cpu usage and hangs there for like 10 minutes.
 
Old 01-18-2005, 11:06 AM   #2
LasseW
Member
 
Registered: Oct 2004
Distribution: Fedora 7, OpenSuse 10.2
Posts: 108

Rep: Reputation: 15
Use df -M to see if you're running out of space in the filesystem and df -i to see if you're running out of inodes. top will show you which processes consume cpu and memory.
 
Old 01-18-2005, 11:18 AM   #3
davesbedroom
LQ Newbie
 
Registered: Jan 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Thanks for the help!
I don't have the option of df -M, but I used df -h to see how much I had left. What does the -M option do?

when i did df -i this is what I received for the device the directory is on.
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda3 3.2M 399K 2.8M 13% /

That means I should be good to go for a long time correct? I shouldn't worry about having too many files in one directory (300,000+ files)?
 
Old 01-18-2005, 01:19 PM   #4
davesbedroom
LQ Newbie
 
Registered: Jan 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Is there any danger of crashing the system while moving the files out of this directory?
 
Old 01-18-2005, 01:50 PM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
If the previous posting was a complete listing:

Quote:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda3 3.2M 399K 2.8M 13% /
It would seem that you only have one partition on your machine.

If this is the case, are the majority of these files in on directory?

This would cause an overhead with the client machine trying to get the information of all of these files to provide a directory list and would most likely be the cause of the "hang"

As a test, create a directory called example: mkdir example

List the latest 1000 files and copy them to example (note this creates duplicates of these files):

Code:
ls -lt|head -1000|while read v_file
do
   cp -p $v_file example/.
done
Then on your samba client look at the example directory and see how long it takes to compile the list.

Assuming this takes a short while to come back, I would suggest you have a period of organisation ahead of you.

Hope this helps
 
Old 01-18-2005, 01:53 PM   #6
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Sorry,

Just saw a bug in my example!

ls -lt will cause errors

try ls on it's own!
 
Old 01-18-2005, 02:11 PM   #7
davesbedroom
LQ Newbie
 
Registered: Jan 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Yes I'm sure the hang was caused by windows weak ability to handle a large directory list. (yay for them!)

The hang up it caused has made me afraid to even go into the directory through the shell and do a simple "ls" for fear or bringing the server down. Should I have anything to be afraid of?

what about "ls -rt" ?

what does "ls | head -1000" do?
 
Old 01-19-2005, 12:52 AM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
OK

LS (in lower case) is the Unix/Linux command to list files in a directory (equivilant to dir), so you would need to do my suggestion on the Samba file server itself (not from the client machine)

ls | head -1000

redirects the output of LS to the command HEAD. The charecter in between is called a pipe, and would be shown on your keyboard as a line with a gap in the middle.

The head command takes the first 1000 entries from the previous command.

These can then be passed to the next command:

while read v_file

This starts a while do done loop and reads input into the v_file variable for each loop

cp -p $v_file example/.

copies the file stored in the v_file parameter to the directory example calling the file the same name and keeping the ownership security permissions and timedate stamp information from the original file.
 
Old 01-19-2005, 08:11 AM   #9
davesbedroom
LQ Newbie
 
Registered: Jan 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Disillusionist
You're script is the best! Do you have a good book to recommend for /bin/sh scripts? I am pretty good with perl so I figure the oreilly books sould be pretty good right?
 
Old 01-19-2005, 01:10 PM   #10
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Yep, I tend to go with O'Reilly books.

Probably one of the best alround books is "Unix Power Tools"

This covers:
* the various types of scripting languages available (including bourne, c, korn and perl)
* powerful utilities like sed and awk
* text editors (vi and emacs)

and much more.

It even has the best part of a chapter dedicated to working with Samba.

It's quite a chunky book but well worth it!
 
Old 01-19-2005, 02:34 PM   #11
davesbedroom
LQ Newbie
 
Registered: Jan 2005
Posts: 27

Original Poster
Rep: Reputation: 15
what distro is colinux ?
 
Old 01-19-2005, 03:38 PM   #12
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
colinux is "Cooperative Linux"

Check out their site on www.colinux.org

Basically, it allows you to run a linux kernel from within the Windows Operating System
 
  


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
Big O, Big Omega, and Big Theta oulevon Programming 7 05-26-2010 07:18 AM
how to find out how big is a directory xpucto Linux - Newbie 7 10-04-2005 02:12 AM
Big, big Problem on vsftpd rhonneil Linux - Newbie 1 10-01-2003 02:18 PM
Installing RH 9 with RAID 5 --Big, big Problem!!! rhonneil Linux - Software 2 09-25-2003 08:13 PM
Overfilled message queue. I need very ugent help! J_Szucs Linux - Software 2 05-23-2002 09:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:08 AM.

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