How do I delete this file in linux?

We had a hard drive crash which we were able to mostly recover from.
There are a few files on this disk that appear to no longer exist yet I can't create a file with the same name, nor can I delete it.  See vmware-24.log from the ls output below for an example

ls -al *.log
ls: vmware-24.log: No such file or directory
-rw-r--r--    1 root     root        19683 Nov  1 06:15 vmware-20.log
-rw-r--r--    1 root     root        20739 Nov  1 11:06 vmware-21.log
-rw-r--r--    1 root     root        34357 Dec 10 03:56 vmware-22.log
-rw-r--r--    1 root     root        43128 Jan  8 08:31 vmware-23.log
-rw-r--r--    1 root     root        29251 Jan 16 09:58 vmware-25.log
-rw-r--r--    1 root     root        27455 Jan 22 15:44 vmware-26.log
-rw-r--r--    1 root     root       134046 Feb  5 11:17 vmware.log

rm vmware-24.log
rm: cannot lstat `vmware-24.log': No such file or directory

And if I try to save a file with that name using VI:
"vmware-24.log"
"vmware-24.log" E212: Can't open file for writing
LVL 3
friekedAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
If none of that works then I'm all out.

Given the state of this file system I'd strongly suggest you back up all your important data, verify it and then wipe and recreate it. Hopefully that won't mean re-imaging the box but if it does I still think you would be better off doing it. Currently you are operating on a file system that has questionable integrity and, as such, you don't know what else may be going wrong under the hood. You might run for days or weeks without a problem and then eventually discover that over this time your important data has been getting corrupted and you've been backing it up and over-written all your good backups with corrupt data!

Personally, I wouldn't dream of using this server in a production environment -- even if it mean bringing it down for a day or two to rebuild it properly.

Good luck.

-Rx.
0
 
ozoCommented:
did you recover by running fsck ?
0
 
friekedAuthor Commented:
It's a RAID5 array, we had 2 disks go bad and recovered the data from 1 to rebuild the array.
We tried fsck with no luck
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
evilrixSenior Software Engineer (Avast)Commented:
This suggests that the file system is corrupt There is still an inode entry for this file even though it doesn't exist. You say you run fsck, how did you run it? What options did you choose? Was the file system unmounted when you did this? If the file system can't be unmounted you can force a fsck on the file system during boot-up by shutting down with the -F option.

shutdown -r -F now

If this doesn't work try a Google search for "linux file system recovery", which will list a number of useful recovery guides.
0
 
omarfaridCommented:
Is your aim is to copy the files or overwrite them?

If you do not want the files, then try

rm -i *.log

and answer with y to those ones you want to delete.

0
 
friekedAuthor Commented:
rm -i vmware-24.log
rm: cannot lstat `vmware-24.log': No such file or directory
[root@vmware gtcx01]# rm -i *.log
rm: remove regular file `vmware-20.log'? n
rm: remove regular file `vmware-21.log'? n
rm: remove regular file `vmware-22.log'? n
rm: remove regular file `vmware-23.log'? n
rm: cannot lstat `vmware-24.log': No such file or directory
rm: remove regular file `vmware-25.log'? n
rm: remove regular file `vmware-26.log'? n
rm: remove regular file `vmware.log'? n
0
 
omarfaridCommented:
Hi,

If you want to keep the other log files, you may copy them to some other dir, and when the vmware-24.log file is the only file left, go one level up in the dir hierarchy and run

rm -r -y dir
0
 
Duncan RoeSoftware DeveloperCommented:
What file system type have you got? I ask this because if it's xfs, then fsck is always a no-op (check the man page for fsck.xfs:). You need to run xfs_repair to actually fix anything, preferably with the system in single-user mode
0
 
friekedAuthor Commented:
File system type is ext3
I have tried the forced fsck on reboot with same result afterwards.
0
 
omarfaridCommented:
If you are in that dir where the files are, can you create new files / dir?

Try

touch myname

and see if you get errors.
0
 
friekedAuthor Commented:
@omarfarid Yes, everything works normally except for these files and this server is still in production as a VMware esx 3.01 host.
0
 
omarfaridCommented:
Can delete that dir that contains the log file and recreate it (please note the ownership, and permissions before deleting)?

0
 
evilrixSenior Software Engineer (Avast)Commented:
You could try this: Copy all the files you can to a new dir, then rename the old dir and rename the new dir as the old dir. If all is well remove the old dir.

NB. I'd suggest you ensure you have a backup before you try anything that might prove destructive to the existing data.
0
 
friekedAuthor Commented:
@evilrix  Tried that already.  See example below If the directory is completely empty (except for one of these files) and I try to rm -rf the directory

rm -rf gfs01
rm: cannot remove directory `gfs01': Directory not empty
0
 
evilrixSenior Software Engineer (Avast)Commented:
Can you mv it though?
0
 
omarfaridCommented:
One more try:

rm -r -d -f dir
0
 
friekedAuthor Commented:
Yes, I can move/rename the directory containing one of the files.  That's an ok work-around but I'd still like these files deleted.
0
 
friekedAuthor Commented:
@omarfarid same result:
rm -r -f -d gfs01/
rm: cannot remove directory `gfs01/': Directory not empty
0
 
omarfaridCommented:
In that case, I go with evilrix work around to rename the dir and recreate a new one.
0
 
evilrixSenior Software Engineer (Avast)Commented:
Ok, so what about if you try moving the directory to another file system? Once you can then trash (such as a floppy)?
0
 
evilrixSenior Software Engineer (Avast)Commented:
Also, have you tried recreating the (a!) file?

touch vmware-24.log

or

cat /dev/null >> vmware-24.log

What does that do?
0
 
friekedAuthor Commented:
Moving within the same file system works.  Once I try to move it to another file system I get the same error
mv: cannot stat `gfs01/gfs01.vmxf': No such file or directory

Both the touch and cat commands say the file already exists.
touch vmware-24.log
touch: creating `vmware-24.log': File exists
cat /dev/null >> vmware-24.log
-bash: vmware-24.log: File exists
0
 
evilrixSenior Software Engineer (Avast)Commented:
Then, at this point without access to the box to play and without being able to recreate your problem (thankfully :) ) I am out of ideas. Can I suggest you consider my suggestion above?

Anyway, sorry I was unable to help.

-Rx.
0
 
friekedAuthor Commented:
@evilrix  Thanks for the suggestions, if all else fails I will probably end up using vmware vmotion to relocate these VM's to another server temporarily and then formating the filesystem
0
 
bummerlordCommented:
I think vmware.log is usually located on VMFS in ESX. Are these log files under /vmfs somewhere?
If the vmfs file system is corrupt none of the ext file system tools will help you.
If you are using vmfs in a clustered setup, I would guess moving the instances to another node will not help as the "VM" (that is actually just a set of files) will still remain on the shared storage, and you certainly will not want to reformat the shared storage!? (assuming you actually can do that from within the service console when vmfs is busy)
As we don't know much about your ESX setup, nor the importance of what is hosted on them, I would suggest you to contact vmware support on this one.




0
 
swallace1986Commented:
Does ls -li show an inode for vmware-24.log or do you still get "ls: vmware-24.log: No such file or directory"?
0
 
swallace1986Commented:
If you get an inode number for the file, go to the directory where vmware-24.log is located and try this:

find . -inum <inode number> -exec rm {} \;

All depends on being able to get the inode number for the file.

Stephen
0
 
friekedAuthor Commented:
None of the solutions worked, I rebuilt this esx server.
0
 
evilrixSenior Software Engineer (Avast)Commented:
>>I rebuilt this esx server.
Didn't I suggest this would be the best course of action? {http:#20827309}
0
 
friekedAuthor Commented:
You did suggest that, however that was a work-around that I was hoping to avoid and not a solution for the question that was asked.
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> not a solution for the question that was asked
Just because an answer isn't one you want to hear doesn't make it any less correct. Ultimately, it was the only way to resolve your problem... as I suggested may be the case. Since no other solution offered worked and since this did (since it was how you eventually resolved it) I think my answer is valid.
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> Just because an answer isn't one you want to hear doesn't make it any less correct
Or, putting it another way...

"Please remember that if the answer to your question is 'You can't do that' you still received an answer"
Step 4: Assign Points
http://www.experts-exchange.com/help.jsp#hi86
0
 
friekedAuthor Commented:
Your answer wasn't "You can't do that"
Your answer was: I didn't answer your question and I'm all out of ideas so format instead.

It is trivial to say "go wipe your system and your problem will be gone"  In fact, why don't I just go say that to every unanswered question, I mean it is an answer after all.
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> It is trivial to say "go wipe your system and your problem will be gone"
Your point would be valid had I not tried many other ways to resolve this first but I eventually concluded, after making many suggestions and taking into consideration the suggestions of others, that there was no other way to resolve your problem. To this end I suggested wiping it as the only way forward. It seems I was right.

>> why don't I just go say that to every unanswered question, I mean it is an answer after all.
You are not making a fair point. I tried to suggest (as did others) many ways to resolve this before I reached my conclusion. The fact is my conclusion was correct.

Anyway, I'm sure we could bat this back and forth all day but the point is I object to your request to delete this Q for the reasons I've given. This will, of course, mean a moderator will review this thread and arbitrate. I am happy to accept whatever they decide but, on balance, My answer was; however, correct and is therefore (IMO) a valid answer for the PAQ database with regards to this question. I'm sorry you disagree.
0
 
evilrixSenior Software Engineer (Avast)Commented:
Ok, so you've now accepted a random answer (that clearly does not answer the question in any possible way) just to avoid selecting the correct answer. Fine, I've posted a request for attention in CS for administrative action so that a moderator can deal with this {http:Q_23138562.html}.

Just so you know, the point of selecting an answer is to build a PAQ (previously Asked Question) database of answers that are valid solutions to the problem. In this case my answer was the only valid solution; evident since that was the action you ended up taking). Just because it's not what you wanted to do does not make it any less valid!
0
 
evilrixSenior Software Engineer (Avast)Commented:
Oops, wrong Url provided... I'll try again...

FYI: I've posted a request for attention in CS for administrative action {http::Q_23533895.html}
0
 
swallace1986Commented:
Hey group,

Not to stir up the muddy water, but I kind of take offense at everyone ditching my comment as having no value to this question.  Anyway, no big deal.  Whatever.  
0
 
friekedAuthor Commented:
swallace1986, your comment had about as much value as any other in my opinion.  
0
 
swallace1986Commented:
frieked,

Thank you.  I don't want to get involved in any trouble on this thread, just kind of felt like the answer I'd provided was valid and kind of being regarded as useless or stupid.  Good luck.  Glad you got your issue resolved.

Stephen
0
 
friekedAuthor Commented:
No problem, I'm not gonna monitor this thread any longer but if I have any say left I hope you at least get a split.
0
 
evilrixSenior Software Engineer (Avast)Commented:
>>  I kind of take offense at everyone ditching my comment as having no value to this question
Hi swallace1986.

I never said that (I don't think anyone did). The point is the action taken to resolve this problem was what I suggested should be done but that's not the answer frieked selected. It is blatantly obvious frieked just selected the last answer in this thread, posted by anyone other than me, as an attempt to avoid having to select my answer. Please don't take this as me suggesting your comment didn't add value, they all did, but in the end there was only one course of action that could be taken and it is what I suggested earlier in this thread and as such that is the answer that should be selected.

See my point above, "the point of selecting an answer is to build a PAQ (previously Asked Question) database of answers that are valid solutions to the problem".
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> I hope you at least get a split.
For what reason exactly? There is only one answer in this thread that is correct and that is mine. How does the answer you selected in any way solve your stated problem?
0
 
swallace1986Commented:
evilrix,

No worries.  I shouldn't have even posted replies, pride was messing with me :-)

Stephen
0
 
evilrixSenior Software Engineer (Avast)Commented:
No worries Stephen, sorry for any misunderstanding :)
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> The asker is free to close it properly.
I'd also like to point out that you did originally thank me for the suggestion and said you may follow it. It seems odd that since you did end up following that suggestion you are now reluctant to accept it as the answer. {http:#20827386}
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> I think the point has been made.
You're right... it has.
0
All Courses

From novice to tech pro — start learning today.