LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (http://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Can't delete directory and files (http://www.linuxquestions.org/questions/linux-enterprise-47/cant-delete-directory-and-files-4175445959/)

Anup D. 01-16-2013 10:55 PM

Can't delete directory and files
 
Hello Friends,

My one of the OpenVZ container backup failed and it had created it's tmp directory:
# ls -l /backups/vps/2013-Jan-14
drwxr-xr-x 4 root root 4096 Jan 15 03:26 vzdump-openvz-101-2013_01_14-22_50_09.tmp

This above directory contains some below files :
# ls -ila
total 8250080393
24609288 drwxr-xr-x 1 10009 2524 4096 Jan 17 03:23 .
24609283 drwxr-xr-x 3 10009 2524 4096 Jan 17 03:23 ..
25165834 br-srwSr-T 8274 824200736 976835141 32, 57 Nov 12 2022 btn_bg-disabled.gif
25165836 br-sr---wt 14128 1280210021 1998600761 78, 95 Apr 2 1987 btn_cgi_bg.gif
25165837 br-xr-srwT 8265 1415275040 1969771331 91, 32 Aug 15 2011 btn_coldfusion_bg.gif
25165839 dr-s--xrwT 19744 540035423 808613224 1230193491 Mar 9 1987 btn_miva_bg.gif
25165840 dr-x--x--t 21573 1801670239 1952796192 1635197004 Sep 13 2028 btn_ok_bg.gif
25165841 c---r----- 12849 1735285536 1646276658 110, 105 Nov 15 1999 btn_perl_bg.gif
25165843 ?--Srwx--T 28265 1263416624 1230987808 825242144 Jan 10 2026 btn_python_bg.gif
25165844 ?r--r----T 14641 1128883055 1314857017 175400299 Jan 2 2011 btn_refresh-list_bg.gif
25165845 ?--xr-s--x 17235 538996329 1528842591 1768038503 Oct 20 2014 btn_ssi_bg.gif
25165846 br-x--xr-x 8268 1735270514 1948274271 110, 105 Sep 7 1996 dBox-footer-bg.gif
25165847 d--s-wSr-- 26708 976768585 858872608 1397317451 Sep 15 2006 dBox-header-left.gif
25165848 ?r-SrwS-w- 8303 1931495758 1668248608 1280204611 Sep 13 2028 dBox-header-right.gif

I want to delete above all files but is not allowing to do so.
Whenever I try to delete those it gives below error:
# rm -rf btn_bg-disabled.gif
rm: cannot remove `btn_bg-disabled.gif': Operation not permitted

I tried to delete using inode values but the error is same.
# find . -inum 25165841 -exec rm -i {} \;
rm: remove write-protected character special file `./btn_perl_bg.gif'? y
rm: cannot remove `./btn_perl_bg.gif': Operation not permitted

Please help me to delete this files.

Thanks
Anup

jpollard 01-17-2013 04:43 AM

It looks like you may have a corrupted filesystem.

I don't think having device files show up like that can be anything else.

Now it is possible to get that error on systems running SELinux - it usually is caused by going to root with "su" instead of "su -" before trying to delete files with security labels than prevent deletion.

shivaa 01-26-2013 04:03 AM

Many of these files have SUID or SGID set, plus some of them do not have write permission also.

So if your motive is just to remove these files, then you can try to change their permission mode first and then remove SUID/SGID. And then try to remove files as:-
Code:

~$ cd /backups/vps/2013-Jan-14
~$ chmod 777 ./*
~$ chmod u-s,g-s,a-t ./*
~$ rm -rf <filename>

To me, these files look corrupt (you can see garbled link count, owner and group attributes).

jpollard 01-26-2013 09:19 AM

Just as a note - it isn't necessarily the files that are corrupt.

It is the inode that is corrupt. And that points to a disk error or other much worse filesystem corruption.

Deleting the files could just make things worse as freeing up these inodes would make them available for reuse- which could also get corrupted. There is also the problem of the blocks released - if the problem carries on into the filesystem data, (such as duplicate allocations) doing this could cause the other files (which are not yet corrupt) to become corrupted.

you really need to dismount this filesystem and run fsck to see what it reports as bad.


All times are GMT -5. The time now is 06:07 PM.