cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot delete file in dbfs

erigaud
Honored Contributor

Hello, 

I am trying to delete a folder in /dbfs/mnt, but I am unable to do so. The folder was an old mounted storage account, which was deleted. The folder contains a single file 'mount.err'.

In command line I tried rm -rf my_folder, with and without sudo. I also tried to rename the folder. 

Whatever I try, I get the following error : rm: cannot remove 'my_folder/mount.err': Input/output error

I also tried in a notebook and with dbutils, but one again without success.

I tried repairing the filesystem with fsck.ext4, without success.

Please let me know if someone has a solution, thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Priyanka_Biswas
Valued Contributor
Valued Contributor

Hi @erigaud  The issue you're facing might be due to the fact that the folder was a mounted storage account that has been deleted. This could cause some inconsistencies in the file system view and hence, you're unable to delete the folder.
You can try using Databricks Utilities to refresh the mounts and then attempt to delete the folder again.
Here is the command you can use in Databricks notebook:

python
dbutils.fs.refreshMounts()
dbutils.fs.rm("/mnt/my_folder", recurse=True)

This command will refresh the state of the mounts in your workspace and then attempt to delete the folder recursively.

View solution in original post

2 REPLIES 2

Priyanka_Biswas
Valued Contributor
Valued Contributor

Hi @erigaud  The issue you're facing might be due to the fact that the folder was a mounted storage account that has been deleted. This could cause some inconsistencies in the file system view and hence, you're unable to delete the folder.
You can try using Databricks Utilities to refresh the mounts and then attempt to delete the folder again.
Here is the command you can use in Databricks notebook:

python
dbutils.fs.refreshMounts()
dbutils.fs.rm("/mnt/my_folder", recurse=True)

This command will refresh the state of the mounts in your workspace and then attempt to delete the folder recursively.

Hello,

Thanks for the answer !

The problem was indeed coming from a broken mount point. After running the refreshMounts() command, I still was not able to remove the folder, because the command was throwing a NullPointerException. However I was able to run the dbutils.fs.unmount command on the broken folder (even though before it did not work and the folder was not showing up when I was trying to list all the mounts.

After running the unmount command I was able to delete the folder just fine. Thank you !

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.