Why can't I delete this directory?

6

1

Transcript:

$ ls -al
total 0
drwxrwxrwx 1 root root 8 Jun 14 05:13 .
drwxrwxrwx 1 root root 6 Jun 14 04:57 ..
drwxrwxrwx 1 root root 0 Jun 12 00:29 DARN
$ ls -al DARN/
total 0
drwxrwxrwx 1 root root 0 Jun 12 00:29 .
drwxrwxrwx 1 root root 8 Jun 14 05:13 ..
$ sudo lsof | grep DARN
$ sudo rmdir DARN
rmdir: failed to remove 'DARN': Operation not permitted

I can rename the directory, I can even move it outside of its parent. Reboot didn't help either.

This is Arch Linux 4.0.5-1-ARCH (current).

Update: Dan suggested extended attributes:

$ sudo lsattr .
---------------- ./DARN
$ sudo lsattr DARN/
$ 

I guess that means there aren't any?

Johannes Ernst

Posted 2015-06-14T05:19:48.847

Reputation: 775

1Use chattr/lsattr to check for things like immutable flag – Dan – 2015-06-14T06:58:00.623

2Two questions: on which filesystem is DARN located (ext4, fat32,...), and can you post the output of ls -id * issued in DARN's parent directory. – MariusMatutiae – 2015-06-14T08:37:47.137

@MariusMatutiae: 1) btrfs. 2) 256 DARN – Johannes Ernst – 2015-06-15T17:23:08.460

Pls read my answer and let me know. – MariusMatutiae – 2015-06-15T17:36:39.210

Answers

6

From the BTRFS FAQ:

if you get:

rmdir: failed to remove ‘emptydir’: Operation not permitted

then this is probably because "emptydir" is actually a subvolume. You can check whether this is the case with:

 # btrfs subvolume list -a /mountpoint

To delete the subvolume you'll have to run:

 # btrfs subvolume delete emptydir

This is apparently a well-known problem, with a well-defined solution. If this works, I would also run

  btrfs check --repair /dev/sdXY

just in case.

If all else fails, run

     lsof +D /path/to/DARN

from outside DARN, and see whether anything is actually accessing the directory so fast that you cannot see it.

MariusMatutiae

Posted 2015-06-14T05:19:48.847

Reputation: 41 321

You got it! Must be that systemd-nspawn turned this into a subvolume when I was playing around with it. – Johannes Ernst – 2015-06-15T18:03:35.907