# Cannot rmdir a previously readonly directory



## aspoon (Apr 1, 2014)

I previously followed something similar to https://wiki.freebsd.org/RootOnZFS to have boot/root on ZFS on FreeBSD 9.0-RELEASE.  Note that (as per the guide) /var/empty was a separate ZFS filesystem with `readonly=on`.

I've recently installed a fresh 10.0-RELEASE, and used good ol' `cp -R ...` to copy the old /var (from the ZFS root above) onto a different ZFS pool as a backup.  But now I cannot remove or modify the backup of /var/empty:


```
# cd /pool/backup/var
# ls -al empty
total 17
dr-xr-xr-x   2 root  wheel   2 Jan  3  2012 ./
drwxrwxrwx  24 root  wheel  24 Dec 11 18:28 ../
# chmod 777 empty
chmod: empty: Operation not permitted
# rmdir empty
rmdir: empty: Operation not permitted
#
```

Does anybody know of the reason why this is the case, and whether there is a way to get rid of this folder?

Thanks!

Alvin


----------



## usdmatt (Apr 1, 2014)

What does the output of `mount` look like.


----------



## kpa (Apr 1, 2014)

The folder is protected from deletion using file flags (see chflags(1)), in this case the schg flag. If you want to delete the folder you have to clear the flag:

`chflags noschg /var/empty`


----------



## aspoon (Apr 1, 2014)

kpa said:
			
		

> `chflags noschg /var/empty`



Yeah!  Problem solved!  Thanks!


----------

