Unable to list contents/remove directory (linux ext3)
Solution 1:
I am presumming you are doing this on an ACTIVE filesystem. Thus it is possible that while you are doing the find and such, the file got deleted before it could be processed by find. This would be ok.
What I might do to get a list of files is NOT to use ls. ls tries to do a sort and with a directory that size it would take pretty long just to get the list and then get it sorted.
What I do in such cases is (as the root user):
find dirname -ls >outfile
If you want to delete something based on times:
find dirname -type f -mtime +60 -print0 | xargs -0 rm -f
BTW, the -0 and -print0 are options in Linux so that filenames with "special" characters are passed properly to xargs. The above of course removes files that have been modified GREATER THAN 60 days before now.
Solution 2:
Here's an easy way to determine if the filesystem needs repair, or at least understand how extensive the damage is...
Download the (free) R1Soft/Idera Hot Copy snapshot utility. This is an RPM and kernel module that provides copy-on-write snapshots of Linux filesystems without the need to have LVM, etc. in place.
Let's say your filesystems look like:
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 12G 4.4G 7.0G 39% /
tmpfs 14G 0 14G 0% /dev/shm
/dev/sda1 291M 166M 110M 61% /boot
/dev/sda3 9.9G 2.5G 7.0G 26% /usr
/dev/sdb1 400G 265G 135G 67% /home
You could use Hot Copy to snapshot /home
without mounting the resulting filesystem... Then run a fsck
to see if there are any issues.
hcp --skip-mount /dev/sdb1
fsck -a /dev/hcp1
This can save you the time of the reboot and help you assess the severity before scheduling client downtime.
Long-term, I'd just use XFS as the filesystem... But that's another topic...