-1

I have a directory on a file system that I can't delete. I have tried

rm -rf My_dir

but the directory persists. So I ran

stat My_dir

and it returned the following:

-bash-3.2$ stat My_dir
File: `My_dir'
Size: 0             Blocks: 0          IO Block: 4096   directory
Device: 801h/2049d  Inode: 191961      Links: 4294967278
Access: (0777/drwxrwxrwx)  Uid: (   48/  apache)   Gid: (  100/   users)
Access: 2017-02-25 21:49:02.000000000 +0000
Modify: 2017-02-25 22:19:45.000000000 +0000
Change: 2017-02-26 05:03:46.000000000 +0000

As you can see the directory has an interesting amount of Links so I assume it may be corrupted. So I got to running fsck as I hoped it would be straight forward for it to discover and fix the issue, however, it returned

-bash-3.2$ /sbin/fsck /dev/sda1
fsck 1.39 (29-May-2006)
Refusing to operate on read-write mounted device /dev/sda1.

then trying to

umount /dev/sda1

returned

umount: /my_device: device is busy

Im wondering if I can get around the whole fsck business and force a delete in some other way?

(I'm a bit of a novice in this world BTW)

EDIT#1

I'd been using sudo to push commands through already. But the problem persisted.

As an update. After a restart of the drive with the corrupted folder, the problem directory appeared to return the following after calling stat:

File: `My_dir'
Size: 4096          Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d  Inode: 191961      Links: 1
Access: (0777/drwxrwxrwx)  Uid: (   48/  apache)   Gid: (  100/   users)
Access: 2016-11-04 10:29:27.000000000 +0000
Modify: 2016-11-04 10:30:06.000000000 +0000
Change: 2016-11-04 10:30:06.000000000 +0000

However, after executing

ls -l | less

To try and escape any hidden chars, the problem returned

File: `My_dir'
Size: 0             Blocks: 0          IO Block: 4096   directory
Device: 801h/2049d  Inode: 191961      Links: 4294967295
Access: (0777/drwxrwxrwx)  Uid: (   48/  apache)   Gid: (  100/   users)
Access: 2016-11-04 10:29:27.000000000 +0000
Modify: 2017-02-26 10:29:15.000000000 +0000
Change: 2017-02-26 10:30:36.000000000 +0000

Notice the timestamps and how they differ as well... confused?

  • Just wanted to note that 4294967278 is -17 in 32-bit arithmetic. So it really looks corrupted. As for fsck, you cannot perform it on a mounted file system, and you cannot easily unmount it live since it's your root. See this question for a possible solution. Checking the file system is more than advised if you are suspecting its corruption, since many more other files can actually be affected. – undercat Feb 26 '17 at 7:11
  • 1
    There is most likely a process that still has a deleted file open in there open. lsof My_dir/. to see what processes use it. Note that if you want to know why rm doesn't succeed, you should run it without the -f which hides the errors. Also note that the parent directory permissions are more important than the folder's permissions in this case (file/folder permissions don't matter since you're changing the parent). – Julie Pelletier Feb 26 '17 at 7:36
  • Your edit doesn't show any of the clarifications I asked. It also doesn't that you tried to fsck the partition when it's unmounted. The simplest way to do it would be from a bootable USB stick. – Julie Pelletier Feb 27 '17 at 6:09
0

This may be more basic of an answer than you're looking for, but if you haven't already, I'd suggest running this with sudo or as root to make sure that there isn't some obscure, unexpected, or silly file permissions issue getting in your way. Good luck!

0

Yes, it looks like a corrupt filesystem. Boot your system with a recovery- or live linux like grml.org and start the fsck again. But beware, if fsck repairs the filesystem, there could be many files purged. Save your important files before with rsync to another host or volume. Better you exclude the corrupt directory!

# mount -o ro /dev/sda1 /mnt
# rsync -av --exclude="*/My_dir/*" /mnt/ /usb-drive/backup/
# umount /mnt
# fsck /dev/sda1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.