 |
 |
 |
 |
| Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum. |

1st July 2008, 08:38 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 30

|
|
|
Cannot remove file: rm file not found
I have a file on an external hard drive that appears to be corrupted. I tried deleting the file and rm returns
Code:
rm: cannot remove : No such file or directory
If I run ls on the directory I can see the file clearly and running ls --size shows it to take one block.
I need a way to delete this file if anyone has any suggestions I appreciate it.
|

1st July 2008, 09:59 PM
|
 |
Retired User
|
|
Join Date: Oct 2004
Location: London, UK
Posts: 4,999

|
|
you can try unlinking it (as root)
or delete it via its inode, change to the directory containing the file and type something like
Code:
find . -inum $(ls -i <filename>) -exec -rm -i {} \;
|

1st July 2008, 10:18 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 30

|
|
|
I tried both suggestions but I still get the same "No such file or directory" error.
|

1st July 2008, 10:22 PM
|
 |
Registered User
|
|
Join Date: Oct 2007
Location: Freedonia
Age: 63
Posts: 2,107

|
|
|
Try using emacs in dired mode. If your drive is at /media/harddrive, you'd use this command:
emacs /media/harddrive
and emacs will allow you to edit the directory itself. It may be that there's a non-printing character in the file name, and if so, simply deleting all the characters in the name and entering a new one may be all you need.
__________________
Registered Linux user #470359 and permanently recovered BOFH.
Any advice in this post is worth exactly what you paid for it.
|

1st July 2008, 10:27 PM
|
 |
Retired User
|
|
Join Date: Oct 2004
Location: London, UK
Posts: 4,999

|
|
does 'ls -i <filename>' return anything?
what filesystem do you have on the drive? Your file may have an unusual character in its filename, you can try grepping part of the filename eg 'rm $(ls grep <part of filename)'
or copy and paste on the whole file name, or, easiset method, have you tried deleting it from a graphical window like in nautilus (launch as root if necessary)
edit
the find command should have been
Code:
find . -inum $(ls -i <filename> | cut -d" " -f1) -exec rm -i {} \;
Last edited by sideways; 1st July 2008 at 10:32 PM.
|

1st July 2008, 10:39 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 30

|
|
|
ls -i filename does return the inode number. I tried removing directly from the inode number returned by ls and received the same error. It is an ext3 filesystem with Fedora 8.
I can't delete from nautilus or anything because it is a server that doesn't have X installed. I've tried deleting the same file from Windows (it's on an external drive) and received a similar error.
|

1st July 2008, 10:48 PM
|
 |
Retired User
|
|
Join Date: Oct 2004
Location: London, UK
Posts: 4,999

|
|
so you're in the same directory as the file and ls -i <filename> returns the inode? Maybe try it like this
Code:
find . -maxdepth 1 -inum <inode> -exec rm -i {} \;
That'll prevent a recursive search which may be causing problems.
I didn't know about the emacs metthod, perhaps give it a shot if emacs is installed.
|

1st July 2008, 10:53 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 30

|
|
|
I tried your last suggestion and the weird part is that I get the line asking for confirmation of the file and it shows the filename correctly, but when you enter 'y' then it gives "cannot remove regular file no such file or directory"
I tried installing emacs but I've never used it before so I was unsure of how to overwrite the read only in dired mode.
|

1st July 2008, 11:13 PM
|
 |
Retired User
|
|
Join Date: Oct 2004
Location: London, UK
Posts: 4,999

|
|
I don't know about the emacs mode, but you could just go oldschool and install midnight commander, that's a text based gui file browser, press F8 to delete a file.
|

1st July 2008, 11:28 PM
|
 |
Registered User
|
|
Join Date: Oct 2007
Location: Freedonia
Age: 63
Posts: 2,107

|
|
In case you (or anybody else) needs it, here's a tutorial on file management with emacs:
http://xahlee.org/emacs/file_management.html
If you're having permissions trouble, I'd suggest doing the work as root so that you can override them.
__________________
Registered Linux user #470359 and permanently recovered BOFH.
Any advice in this post is worth exactly what you paid for it.
|

1st July 2008, 11:43 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 30

|
|
|
I tried both mc and emacs and both give the same error. They show the file but if you try to perform any command on that file it gives "no such file or directory"
|

1st July 2008, 11:54 PM
|
 |
Registered User
|
|
Join Date: Oct 2007
Location: Freedonia
Age: 63
Posts: 2,107

|
|
|
I gather this drive is connected to a Windows machine. If so, your best bet at this point is probably going to be done on that machine. Ask whoever administers that box to run a scandisk or equivalent on it and see if that helps.
__________________
Registered Linux user #470359 and permanently recovered BOFH.
Any advice in this post is worth exactly what you paid for it.
|

1st July 2008, 11:56 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 30

|
|
|
no the drive is connected to a Fedora 8 server. It is a samba share so I have tried to delete through explorer but that fails also.
|

2nd July 2008, 12:08 AM
|
 |
Registered User
|
|
Join Date: Oct 2007
Location: Freedonia
Age: 63
Posts: 2,107

|
|
|
In that case, you should be about to unmount it, run fsck to correct any corruption then remount it. It's beginning to sound like the corruption isn't in the file itself but in the directory and this might help.
__________________
Registered Linux user #470359 and permanently recovered BOFH.
Any advice in this post is worth exactly what you paid for it.
|

22nd June 2012, 03:29 AM
|
 |
Registered User
|
|
Join Date: Sep 2010
Location: Quebec, Canada
Posts: 26

|
|
|
Re: Cannot remove file: rm file not found
Hi all,
I had a similar prob with a file named "X0=" created in my user tmp folder when testing one of my script that crashed...
I had tried the inode and all kinds of stuff... Sideways... when I read "mc", I went I'm DumbdumbdumbdumbDumb!
Punched mc, delete file, yes, file full of poop = gone!
Dam it !
Thanks a mill man.
*** Reality is merely an illusion, albeit a very persistent one. -- Albert Einstein
(was he talking about a file named reality ??? Probably not...)
__________________
MotherDawg
I do RPMs
I own crappy boxes
GNU/Linux 3.7.9-104.fc17.i686
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting 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
|
|
|
Current GMT-time: 04:25 (Friday, 24-05-2013)
|
|
 |
 |
 |
 |
|
|