Unable to delete Directories "Text file busy"

Nextcloud version : 19.0.0 (Latest at the moment)
Running with Docker Version : nextcloud:latest
Operating system and version : Ubuntu 20.04 LTS

The issue you are facing: Unable to delete Directories

Is this the first time you’ve seen this error? : Yes

Steps to replicate it:


  • Nextcloud Version 19.0.0 (Latest at the moment)
  • NextCloud using Docker on Virtual Box (Ubuntu Server) on Windows10
  • VirtualBox Shared Folder from Windows NTFS
  • NextCloud data folder mapped to docker host directory
  • One of subfolder inside NextCloud data directory is mounted to VirutalBox shared folder


  • Nextcloud shows files and directory correctly both docker host directory and Virtual Box shared directory
  • Able to create and delete FILES inside NextCloud data (docker host) folder and Mounted (Virtual Box Shared) folder using Web interface
  • Able to create folder inside NextCloud data (docker host) folder and Mounted (Virtual Box Shared) folder using web interface


  • But when I try to delete folder inside Mounted (Virtual Box Shared) folder, NextCloud giving me error Error deleting file "New folder"
"message":"rmdir(/var/www/html/data/<NCUserName>/files/<MountedFolder>/New folder): Text file busy at /var/www/html/lib/private/Files/Storage/Local.php#121"

To find out what causing issue I tried below

  • Able to delete folder on ubuntu with www-data user
    sudo -u www-data rmdir /var/www/html/data/<NCUserName>/files/<MountedFolder>/'New folder'
  • Able to delete folder inside docker
    sudo docker exec --user www-data nextcloud_nextcloud_1 rmdir /var/www/html/data/<NCUserName>/files/<MountedFolder>/'New folder'

At this point, It seems to me root cause is something inside Nextcloud

Any help or direction how to go about fixing it.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"***********","level":3,"time":"2020-07-04T04:02:40+00:00","remoteAddr":"","user":"*******","app":"PHP","method":"DELETE","url":"/remote.php/dav/files/<NCUserName>/Books/New%20folder","message":"rmdir(/var/www/html/data/<NCUserName>/files/<MountedFolder>/New folder): Text file busy at /var/www/html/lib/private/Files/Storage/Local.php#121","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36","version":"","id":"**********"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
  'instanceid' => '**********',
  'passwordsalt' => '****************',
  'secret' => '******************',
  'trusted_domains' =>
  array (
    0 => '*********',
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => '*********',
  'dbname' => '*********',
  'dbhost' => 'mariadb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '*********',
  'dbpassword' => '*********',
  'installed' => true,
  "loglevel" => 0,

The output of your Apache/nginx/system log in /var/log/____:


I found the solution to solve this problem.
I faced same problem.

Ubuntu 18.04 on Windows Srv 2016 by using VirtualBox 6.x ,
Install nextcloud by snap, and do “sudo snap connect nextcloud:removable-media”,
Activate external storage support, set local=“mounted windows’ folder”.

I can make, delete, rename file to external storage.
I also able to make, rename foler, but couldn’t delete.

The solution is simple:
rollback VirtualBox’s version to 5.x from 6.x .
It worked fine for me.

I have exactly the same problem here: I have a folder that someone has shared with me - in that folder (and subfolders) I can delete files, but not directories!?

Downgrading VirtualBox is definitly no option and I also have some difficulties in understanding why VirtualBox should cause that trouble?

Anyone here with the same symptoms?

(file system permissions are fine, the oc_file_locks table is empty)

There was the same problem in the same VirtualBox environment.

I resolved this.

vi /var/www/nextcloud/lib/private/Files/Storage/Local.php

126             unset($it);  <---- Add this line before RETURN. --------------
128             return rmdir($this->getSourcePath($path));

** This method has been listed on the next article.

1 Like