I setup some lxc containers (raring) under a /data path to get them off my SSD and I thought they were corrupt so tried to just rm -rf /data/lxc/$name and it clears out all except the rootfs directory. It fails with the error:

sudo rm -rf /data/lxc/$lxcname
   rm: cannot remove ‘/data/lxc/$lxcname/rootfs’: Operation not permitted

Any hints on how I can clear this now empty directory would be appreciated.

  • sudo su and then remove it – Qasim May 22 '13 at 12:29
  • also check lxc-destroy – Qasim May 22 '13 at 12:30
  • sudo su should never be recommended. Use sudo -i Thanks to guntbert – Mitch May 22 '13 at 13:04
  • Even after using sudo -i, I cannot remove the two directories. I still get the same operation not permitted message. – Rick May 25 '13 at 1:14
  • 1
    Is your lxc directory on a btrfs partition? The symptoms are similar to the case where rootfs subdirectory is a btrfs subvolume. – vhallac Jun 23 '13 at 10:26

I was having the same exact problem as you. After reading @vhallac's comment and doing some digging, I discovered that btrfs requires any subvolumes to be deleted before a parent path can be deleted. Subvolumes are removed using the btrfs subvolume delete <subvolume-path> command.

For your case, try first using $ sudo btrfs subvolume delete /data/lxc/$lxcname/rootfs, then you should be able to run the usual sudo rm -rf /data/lxc/$lxcname.

See also: BTRFS command documentation

  • Thanks, I forgot that I decided to test out btrfs on this volume that houses my lose-able data like lxc containers. That worked for getting rid of my old directories. – Rick Jul 8 '13 at 17:17

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.